diff --git a/README.md b/README.md index 75a2d47..83a1b3d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ not affect the data between websockify and the server. ### Websock Javascript library + The `include/websock.js` Javascript library library provides a Websock object that is similar to the standard WebSocket object but Websock enables communication with raw TCP sockets (i.e. the binary stream) @@ -30,6 +31,8 @@ does not contain actual data but is simply a notification that there is new data available. Several rQ* methods are available to read binary data off of the receive queue. +The Websock API is documented on the [websock.js API wiki page](https://github.com/kanaka/websockify/wiki/websock.js) + See the "Wrap a Program" section below for an example of using Websock and websockify as a browser telnet client (`wstelnet.html`). diff --git a/include/websock.js b/include/websock.js index a688f76..49141c8 100644 --- a/include/websock.js +++ b/include/websock.js @@ -17,9 +17,9 @@ // Load Flash WebSocket emulator if needed -if (window.WebSocket) { +if (window.WebSocket && !window.WEB_SOCKET_FORCE_FLASH) { Websock_native = true; -} else if (window.MozWebSocket) { +} else if (window.MozWebSocket && !window.WEB_SOCKET_FORCE_FLASH) { Websock_native = true; window.WebSocket = window.MozWebSocket; } else { @@ -115,6 +115,7 @@ function rQshift32() { (rQ[rQi++] ); } function rQshiftStr(len) { + if (typeof(len) === 'undefined') { len = rQlen(); } var arr = rQ.slice(rQi, rQi + len); rQi += len; return arr.map(function (num) { @@ -122,6 +123,7 @@ function rQshiftStr(len) { } function rQshiftBytes(len) { + if (typeof(len) === 'undefined') { len = rQlen(); } rQi += len; return rQ.slice(rQi-len, rQi); }