diff --git a/README.md b/README.md index 20f8e79..52a0e1f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## websockify: WebSockets support for any application/server -websockify was formerly named `wsproxy` and was part of the +websockify was formerly named wsproxy and was part of the [noVNC](https://github.com/kanaka/noVNC) project. At the most basic level, websockify just translates WebSockets traffic @@ -15,6 +15,20 @@ case the data from the client is not a full WebSockets frame (i.e. does not end in 255). +### 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) +via websockify. This is accomplished by base64 encoding the data +stream between Websock and websockify. + +Websock has built-in receive queue buffering; the message event +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. + + ### Additional websockify features These are not necessary for the basic operation. @@ -49,7 +63,7 @@ These are not necessary for the basic operation. The primary implementation of websockify is in python. There are two other implementations of websockify in C, and Node (node.js) in the -`other` directory. +`other/` subdirectory. Here is the feature support matrix for the the websockify implementations: diff --git a/include/websock.js b/include/websock.js new file mode 100644 index 0000000..94eb21a --- /dev/null +++ b/include/websock.js @@ -0,0 +1,313 @@ +/* + * Websock: high-performance binary WebSockets + * Copyright (C) 2011 Joel Martin + * Licensed under LGPL-3 (see LICENSE.txt) + * + * Websock is similar to the standard WebSocket object but Websock + * enables communication with raw TCP sockets (i.e. the binary stream) + * via websockify. This is accomplished by base64 encoding the data + * stream between Websock and websockify. + * + * Websock has built-in receive queue buffering; the message event + * 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. + */ + + +// Load Flash WebSocket emulator if needed + +if (window.WebSocket) { + Websock_native = true; +} else { + /* no builtin WebSocket so load web_socket.js */ + Websock_native = false; + (function () { + function get_INCLUDE_URI() { + return (typeof INCLUDE_URI !== "undefined") ? + INCLUDE_URI : "include/"; + } + + var start = "