Re: WebSocket API - proposal for binary frame support in JavaScript

On Wed, 27 Jan 2010, John Fallows wrote:
> 
> 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".

Agreed.


> 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.

That's basically what I expect we'll do, in due course. The two things 
blocking support for this right now are (a) getting support for arrays of 
octets in JS, and (b) getting support for any kind of Web Sockets in the 
browsers at all.


> 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.

It's not _exactly_ what we want -- for example, it can't change size, and 
manipulation is really awkward for anything but just running through the 
bits all at once.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Monday, 1 February 2010 08:30:02 UTC