In NDN.expressInterest, call readAllFromSocket directly without using getAsync to pass the interest in hex.
In NDNSocketTransportService.js, remove unused getAsync.
diff --git a/js/ccnxProtocol/modules/ndn-js.jsm b/js/ccnxProtocol/modules/ndn-js.jsm
index 1532ee5..d8117ab 100644
--- a/js/ccnxProtocol/modules/ndn-js.jsm
+++ b/js/ccnxProtocol/modules/ndn-js.jsm
@@ -247,7 +247,7 @@
/** Encode name as an Interest. If template is not null, use its attributes.
* Send the interest to host:port, read the entire response and call
* closure.upcall(Closure.UPCALL_CONTENT (or Closure.UPCALL_CONTENT_UNVERIFIED),
- * new UpcallInfo(this, interest, 0, contentObject)).
+ * new UpcallInfo(this, interest, 0, contentObject)).
*/
NDN.prototype.expressInterest = function(
// Name
@@ -268,7 +268,11 @@
}
else
interest.interestLifetime = 4200;
- var outputHex = encodeToHexInterest(interest);
+
+ var encoder = new BinaryXMLEncoder();
+ interest.to_ccnb(encoder);
+ var outputData = DataUtils.toString(encoder.getReducedOstream());
+ encoder = null;
var dataListener = {
onReceivedData : function(result) {
@@ -293,7 +297,9 @@
}
}
- return getAsync(this.host, this.port, outputHex, dataListener);
+ // The application includes a source file that defines readAllFromSocket
+ // according to the application's communication method.
+ readAllFromSocket(this.host, this.port, outputData, dataListener);
};
@@ -308,13 +314,6 @@
// Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
// Components.utils.import("resource://gre/modules/NetUtil.jsm");
-/** Convert outputHex to binary, send to host:port and call listener.onReceivedData(data)
- * where data is a byte array.
- */
-function getAsync(host, port, outputHex, listener) {
- readAllFromSocket(host, port, DataUtils.hexToRawString(outputHex), listener);
-}
-
/** Send outputData to host:port, read the entire response and call listener.onReceivedData(data)
* where data is a byte array.
* Code derived from http://stackoverflow.com/questions/7816386/why-nsiscriptableinputstream-is-not-working .
@@ -371,6 +370,7 @@
pump.asyncRead(dataListener, null);
}
+
/*
* @author: ucla-cs
* See COPYING for copyright and distribution information.