aboutsummaryrefslogtreecommitdiff
path: root/third_party/websockify/include/websock.js
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/websockify/include/websock.js')
-rw-r--r--third_party/websockify/include/websock.js25
1 files changed, 10 insertions, 15 deletions
diff --git a/third_party/websockify/include/websock.js b/third_party/websockify/include/websock.js
index ccb7d4c1..7d12644e 100644
--- a/third_party/websockify/include/websock.js
+++ b/third_party/websockify/include/websock.js
@@ -1,7 +1,7 @@
/*
* Websock: high-performance binary WebSockets
* Copyright (C) 2012 Joel Martin
- * Licensed under LGPL-3 (see LICENSE.txt)
+ * Licensed under MPL 2.0 (see LICENSE.txt)
*
* Websock is similar to the standard WebSocket object but Websock
* enables communication with raw TCP sockets (i.e. the binary stream)
@@ -35,23 +35,14 @@ if (window.WebSocket && !window.WEB_SOCKET_FORCE_FLASH) {
Websock_native = false;
(function () {
- function get_INCLUDE_URI() {
- return (typeof INCLUDE_URI !== "undefined") ?
- INCLUDE_URI : "include/";
- }
-
- var start = "<script src='" + get_INCLUDE_URI(),
- end = "'><\/script>", extra = "";
-
- window.WEB_SOCKET_SWF_LOCATION = get_INCLUDE_URI() +
+ window.WEB_SOCKET_SWF_LOCATION = Util.get_include_uri() +
"web-socket-js/WebSocketMain.swf";
if (Util.Engine.trident) {
Util.Debug("Forcing uncached load of WebSocketMain.swf");
window.WEB_SOCKET_SWF_LOCATION += "?" + Math.random();
}
- extra += start + "web-socket-js/swfobject.js" + end;
- extra += start + "web-socket-js/web_socket.js" + end;
- document.write(extra);
+ Util.load_scripts(["web-socket-js/swfobject.js",
+ "web-socket-js/web_socket.js"]);
}());
}
@@ -181,7 +172,10 @@ function decode_message(data) {
//Util.Debug(">> decode_message: " + data);
if (mode === 'binary') {
// push arraybuffer values onto the end
- rQ.push.apply(rQ, (new Uint8Array(data)));
+ var u8 = new Uint8Array(data);
+ for (var i = 0; i < u8.length; i++) {
+ rQ.push(u8[i]);
+ }
} else {
// base64 decode and concat to the end
rQ = rQ.concat(Base64.decode(data, 0));
@@ -380,8 +374,9 @@ function close() {
// Override internal functions for testing
// Takes a send function, returns reference to recv function
-function testMode(override_send) {
+function testMode(override_send, data_mode) {
test_mode = true;
+ mode = data_mode;
api.send = override_send;
api.close = function () {};
return recv_message;