Tuesday, March 22, 2011

Easy WebSocket

You want to use websockets? You want to broadcast messages to all connected clients? You don't want to worry about browser compatiblity? You don't want to set up a server? Here's all the code you need.

EasyWebSocket is simple websockets broadcasting. It is perfect for a quick prototype.. getting it going quick. 90% this is all you need if you're doing websocket something.
The API is copied on the WebScocket standard API, thus compatible and easy to learn.

Step 1: You connect the socket to a given url
Step 2: What you send() thru this socket is sent to all sockets connected to the same url

Just include this code in your webpage and it works. See it live.
For more information, look at slides of a talk i did about it.
Additionnaly you can look at a little chat demo on top of it or another one which monitor latency in real time.

Features

  • Same API as WebSocket Standard
  • No Server to setup
  • No cross browser issue
  • No cross origin issue
EasyWebSocket is written by Jerome Etienne.
The code is available on github at EasyWebSocket under MIT license.


https://github.com/jeromeetienne/EasyWebsocket

No comments: