Add library compressing tool; add onopen and onclose callback to NDN class
diff --git a/js/NDN.js b/js/NDN.js
index dd34c0d..4d2adb2 100644
--- a/js/NDN.js
+++ b/js/NDN.js
@@ -12,6 +12,8 @@
* host: 'localhost',
* port: 9696,
* getTransport: function() { return new WebSocketTransport(); }
+ * onopen: function() { console.log("NDN connection established."); }
+ * onclose: function() { console.log("NDN connection closed."); }
* }
*/
var NDN = function NDN(settings) {
@@ -19,9 +21,16 @@
this.host = (settings.host || "localhost");
this.port = (settings.port || 9696);
var getTransport = (settings.getTransport || function() { return new WebSocketTransport(); });
- this.transport = getTransport();
+ this.transport = getTransport();
+ this.readyStatus = NDN.UNOPEN;
+ // Event handler
+ this.onopen = (settings.onopen || function() { console.log("NDN connection established."); });
+ this.onclose = (settings.onclose || function() { console.log("NDN connection closed."); });
};
+NDN.UNOPEN = 0; // created but not opened yet
+NDN.OPENED = 1; // connection to ccnd opened
+NDN.CLOSED = 2; // connection to ccnd closed
/* Java Socket Bridge and XPCOM transport */