Some files is forgotten to be commited...
diff --git a/js/.DS_Store b/js/.DS_Store
index 3aa25a9..80e2e80 100644
--- a/js/.DS_Store
+++ b/js/.DS_Store
Binary files differ
diff --git a/js/WebSocketTransport.js b/js/WebSocketTransport.js
index 49c09a4..83f53d9 100644
--- a/js/WebSocketTransport.js
+++ b/js/WebSocketTransport.js
@@ -161,7 +161,6 @@
bytes.set(hex);
self.ws.send(bytes.buffer);
- console.log('ws.onopen: ws.send() returned.');
}
this.ws.onerror = function(ev) {
@@ -236,6 +235,13 @@
interest.scope = 1;
//var hex = encodeToHexInterest(int);
var binaryInterest = encodeToBinaryInterest(interest);
+ // If we directly use binaryInterest.buffer to feed ws.send(),
+ // WebSocket will end up sending a packet with 10000 bytes of data.
+ // That is, WebSocket will flush the entire buffer in BinaryXMLEncoder
+ // regardless of the offset of the Uint8Array. So we have to create
+ // a new Uint8Array buffer with just the right size and copy the
+ // content from binaryInterest to the new buffer.
+ // ---Wentao
var bytearray = new Uint8Array(binaryInterest.length);
bytearray.set(binaryInterest);
console.log('Send Interest registration packet.');
@@ -244,7 +250,6 @@
CSTable.push(csEntry);
this.ws.send(bytearray.buffer);
- console.log('ws.send() returned.');
return 0;
} else {
diff --git a/js/testing/.DS_Store b/js/testing/.DS_Store
index c13445d..3f0e7ef 100644
--- a/js/testing/.DS_Store
+++ b/js/testing/.DS_Store
Binary files differ
diff --git a/js/testing/test-put-async.html b/js/testing/test-put-async.html
index 315dec8..cece056 100644
--- a/js/testing/test-put-async.html
+++ b/js/testing/test-put-async.html
@@ -23,11 +23,6 @@
if (kind == Closure.UPCALL_FINAL) {
// Do nothing.
} else if (kind == Closure.UPCALL_INTEREST) {
- // Extract the Name from the Interest. var name = upcallInfo.Interest.name;Íž
- // Check that we want to respond to upcallInfo.interest. If yes, construct a ContentObject
- // response, put it to the NDN and return Closure.RESULT_INTEREST_CONSUMED. Else fall
- // through to return Content.RESULT_OK.
- // See linemaker.py for more details.
console.log('AsyncPutClosure.upcall() called.');
var content = document.getElementById('content').value;
var interest = upcallInfo.interest;
@@ -40,17 +35,21 @@
var co = new ContentObject(new Name(nameStr), si, answer, new Signature());
co.sign();
- var hex = encodeToHexContentObject(co);
+ var coBinary = encodeToBinaryContentObject(co);
+ // If we directly use coBinary.buffer to feed ws.send(), WebSocket
+ // will end up sending a packet with 10000 bytes of data. That
+ // is, WebSocket will flush the entire buffer in BinaryXMLEncoder
+ // regardless of the offset of the Uint8Array. So we have to
+ // create a new Uint8Array buffer with just the right size and
+ // copy the content from coBinary to the new buffer.
+ // ---Wentao
+ var bytearray = new Uint8Array(coBinary.length);
+ bytearray.set(coBinary);
- var bytearray = new Uint8Array(hex.length / 2);
- for (var i = 0; i < hex.length; i = i + 2) {
- bytearray[i / 2] = '0x' + hex.substr(i, 2);
- }
-
- upcallInfo.ndn.transport.ws.send(bytearray.buffer);
- console.log('ws.send() finised.');
-
- return Closure.RESULT_INTEREST_CONSUMED;
+ upcallInfo.ndn.transport.ws.send(bytearray.buffer);
+ console.log('ws.send() finised.');
+
+ return Closure.RESULT_INTEREST_CONSUMED;
}
return Closure.RESULT_OK;
};