WebSocket API - proposal for binary frame support in JavaScript

Folks,

We have a proposal for adding support for binary frames to the JavaScript
WebSocket API.

It is desirable for JavaScript applications using WebSocket to speak binary
protocols. Exposing binary frames brings WebSocket closer to the philosophy
of "TCP for the Web".

This will allow JavaScript to use binary network protocols for mail, chat,
messaging, and more without paying the overhead of BASE64 or another
text-based encoding. BASE64 is expensive in terms of bandwidth and CPU on
both the server and the client. Not requiring an additional transformation
also keeps the WebSocket bindings of these protocols closer to the standard
representations over TCP.

We propose that, in addition to strings, WebSocket.send() could take an
Array of octets (integers in the range 0-255), causing a binary frame to be
sent to the server. When a binary frame is received at the browser, the
WebSocket would dispatch a MessageEvent containing the Array of octets for
the binary frame payload.

Note that this approach:

   1) Does not require a change to EcmaScript.

   2) Does not require a change to MessageEvent:
         MessageEvent.data is specified as type "any" and can already be
non-string types (when originating from postMessage, for instance).

    3) Has been used similarly in HTML5:
         In the Canvas 2D context ImageData.data is a CanvasPixelArray.
CanvasPixelArray is an Array of octets, which is exactly how one would want
to represent a WebSocket binary frame payload.

Kind Regards,
John Fallows
-- 
>|< Kaazing Corporation >|<
John Fallows | CTO | +1.650.960.8148
888 Villa St, Ste 410 | Mountain View, CA 94041, USA

Received on Wednesday, 27 January 2010 21:42:28 UTC