Posts

Showing posts from July, 2012

The Definitive Guide to HTML5 WebSocket

Image
The book is on the way now! You can pre-order it here. It has been so much fun and a lot of work but I personally hope you can get a copy and enjoy all the content we're putting together.

Here is part of the book description if you want more information about it:

"The Definitive Guide to HTML5 WebSocket is the ultimate insider’s WebSocket resource. This revolutionary new web technology enables you to harness the power of true real-time connectivity and build responsive, modern web applications.   

This book contains everything web developers and architects need to know about WebSocket. It discusses how WebSocket-based architectures provide a dramatic reduction in unnecessary network overhead and latency compared to older HTTP (Ajax) architectures, how to layer widely used protocols such as XMPP and STOMP on top of WebSocket, and how to secure WebSocket connections and deploy WebSocket-based applications to the enterprise. Build real-time web applications with HTML5."


The b…

The WebSocket bufferedAmount attribute

If you have been working or planning to work with HTML5 WebSocket you may end up transporting large amounts of data and/or you may have the requirement to transport data as fast as possible. 
The WebSocket object has an attribute called bufferedAmount that's particularly useful to check for the amount of data buffered for transmission to the server. You can use the bufferedAmountattribute to check the number of bytes that have been queued but not yet transmitted to the server.
The values reported in that attribute don’t include framing overhead incurred by the protocol or buffering done by the operating system or network hardware.
The code below shows an example of how to use the bufferedAmountattribute to keep sending updates every second, if the network can handle that rate, or at whatever rate the network can handle, if that is too fast.
// Buffering threshold at 10k var THRESHOLD = 10240;

// Create a New WebSocket connection
var mySocket = new WebSocket(“ws://echo.websocket.org/u…