Added Closure.js. Put expressInterest in NDN.js. Use it in ccnxProtocolService.js.
diff --git a/js/NDNSocketTransportService.js b/js/NDNSocketTransportService.js
index aa12588..1f8a93d 100644
--- a/js/NDNSocketTransportService.js
+++ b/js/NDNSocketTransportService.js
@@ -63,7 +63,7 @@
// Finish.
this.onStopRequest();
} catch (ex) {
- dump("onDataAvailable exception: " + ex + "\n");
+ dump("readAllFromSocket.onDataAvailable exception: " + ex + "\n");
}
}
};
@@ -71,50 +71,3 @@
pump.init(inStream, -1, -1, 0, 0, true);
pump.asyncRead(dataListener, null);
}
-
-
-// TODO: This should be moved to the main NDN.js when we agree on how to do non-blocking get.
-// For now, assume this is included after NDN.js and modify it.
-/** Encode message as an Interest, send it to host:port, read the entire response and call
- listener.onReceivedContentObject(contentObject).
- */
-NDN.prototype.getAsync = function(message, listener) {
- if (this.host != null && this.port != null) {
- var output ='';
- message = message.trim();
- if(message==null || message =="" ){
- dump('INVALID INPUT TO GET\n');
- return null;
- }
-
- interest = new Interest(new Name(message));
- interest.InterestLifetime = 4200;
- var outputHex = encodeToHexInterest(interest);
-
- var dataListener = {
- onReceivedData : function(result) {
- if (result == null || result == undefined || result.length == 0)
- listener.onReceivedContentObject(null);
- else {
- var decoder = new BinaryXMLDecoder(result);
- var co = new ContentObject();
- co.from_ccnb(decoder);
-
- if(LOG>2) {
- dump('DECODED CONTENT OBJECT\n');
- dump(co);
- dump('\n');
- }
-
- listener.onReceivedContentObject(co);
- }
- }
- }
-
- return getAsync(this.host, this.port, outputHex, dataListener);
- }
- else {
- dump('ERROR host OR port NOT SET\n');
- }
-}
-