Move the NDN object from ndnProtocolService to NdnProtocolInfo.
diff --git a/js/ndnProtocol/components/ndnProtocolService.js b/js/ndnProtocol/components/ndnProtocolService.js
index 975a6b5..1cac09b 100644
--- a/js/ndnProtocol/components/ndnProtocolService.js
+++ b/js/ndnProtocol/components/ndnProtocolService.js
@@ -16,9 +16,7 @@
Components.utils.import("chrome://modules/content/ContentChannel.jsm");
Components.utils.import("chrome://modules/content/NdnProtocolInfo.jsm");
-function NdnProtocol() {
- this.ndn = new NDN({ getTransport: function() { return new XpcomTransport(); },
- verify: false });
+function NdnProtocol() {
}
NdnProtocol.prototype = {
@@ -67,8 +65,6 @@
newChannel: function(aURI)
{
- var thisNdnProtocol = this;
-
try {
var uriParts = NdnProtocolInfo.splitUri(aURI.spec);
@@ -86,8 +82,8 @@
var requestContent = function(contentListener) {
var name = new Name(uriParts.name);
// Use the same NDN object each time.
- thisNdnProtocol.ndn.expressInterest(name, new ExponentialReExpressClosure
- (new ContentClosure(thisNdnProtocol.ndn, contentListener, name,
+ NdnProtocolInfo.ndn.expressInterest(name, new ExponentialReExpressClosure
+ (new ContentClosure(NdnProtocolInfo.ndn, contentListener, name,
aURI, searchWithoutNdn + uriParts.hash, segmentTemplate)),
template);
};
diff --git a/js/ndnProtocol/modules/NdnProtocolInfo.jsm b/js/ndnProtocol/modules/NdnProtocolInfo.jsm
index 3a5fc79..396aeb9 100644
--- a/js/ndnProtocol/modules/NdnProtocolInfo.jsm
+++ b/js/ndnProtocol/modules/NdnProtocolInfo.jsm
@@ -10,12 +10,17 @@
const Cr = Components.results;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("chrome://modules/content/ndn-js.jsm");
var NdnProtocolInfo = function NdnProtocolInfo(){
};
-NdnProtocolInfo.ndnHubHost = null;
-NdnProtocolInfo.ndnHubPort = null;
+NdnProtocolInfo.ndn = new NDN({ getTransport: function() { return new XpcomTransport(); },
+ verify: false });
+
+// These are set once a connection is established.
+NdnProtocolInfo.connectedNdnHubHost = null;
+NdnProtocolInfo.connectedNdnHubPort = null;
NdnProtocolInfo.ndnHubChangedListenerList = [];
/*
@@ -25,9 +30,9 @@
NdnProtocolInfo.addNdnHubChangedListener = function(listener) {
NdnProtocolInfo.ndnHubChangedListenerList.push(listener);
- if (NdnProtocolInfo.ndnHubHost != null && NdnProtocolInfo.ndnHubPort != null) {
+ if (NdnProtocolInfo.connectedNdnHubHost != null && NdnProtocolInfo.connectedNdnHubPort != null) {
try {
- listener(NdnProtocolInfo.ndnHubHost, NdnProtocolInfo.ndnHubPort);
+ listener(NdnProtocolInfo.connectedNdnHubHost, NdnProtocolInfo.connectedNdnHubPort);
}
catch (ex) {
// Ignore error from the listener.
@@ -40,12 +45,12 @@
* listener in ndnHubChangedListenerList.
*/
NdnProtocolInfo.setConnectedNdnHub = function(host, port) {
- if (host == NdnProtocolInfo.ndnHubHost && port == NdnProtocolInfo.ndnHubPort)
+ if (host == NdnProtocolInfo.connectedNdnHubHost && port == NdnProtocolInfo.connectedNdnHubPort)
// No change.
return;
- NdnProtocolInfo.ndnHubHost = host;
- NdnProtocolInfo.ndnHubPort = port;
+ NdnProtocolInfo.connectedNdnHubHost = host;
+ NdnProtocolInfo.connectedNdnHubPort = port;
for (var i = 0; i < NdnProtocolInfo.ndnHubChangedListenerList.length; ++i) {
try {
NdnProtocolInfo.ndnHubChangedListenerList[i](host, port);