Update websock.js from noVNC

Sync with noVNC as of commit ae510306b5094b55aa08a2a0d15a151704f70993.

The main change is to make it a more proper object that you can
instantiate multiple times.
This commit is contained in:
Pierre Ossman
2017-02-03 16:25:15 +01:00
parent 10e13d7a7e
commit 3f8f301d7f
2 changed files with 340 additions and 271 deletions
+7 -5
View File
@@ -91,8 +91,8 @@
now = (new Date()).getTime(); // Early as possible
arr = ws.rQshiftBytes(ws.rQlen());
first = String.fromCharCode(arr.shift());
last = String.fromCharCode(arr.pop());
first = String.fromCharCode(arr[0]);
last = String.fromCharCode(arr[arr.length-1]);
if (first != "^") {
message("Error: packet missing start char '^'");
@@ -104,9 +104,11 @@
disconnect();
return;
}
arr = arr.map(function(num) {
return String.fromCharCode(num);
} ).join('').split(':');
text = ''
for (var i = 1; i < arr.length-1; i++) {
text += String.fromCharCode(arr[i]);
}
arr = text.split(':');
seq = arr[0];
timestamp = parseInt(arr[1],10);
rpayload = arr[2];