This plug-in is used to send and receive the JSON object directly with Web Sockets API.
Usage
Connection
var ws = $.websocket("ws://127.0.0.1:8080/");
Sending Message
ws.send('hello'); // sending message is '{type:'hello'}'. ws.send('say', { name:'foo', text:'baa'}); // sending message is '{type:'say', data:{name:'foo', text:'baa'}}'
Event Handling
var ws = $.websocket("ws://127.0.0.1:8080/", { open: function() { ... }, close: function() { ... }, events: { say: function(e) { alert(e.data.name); // 'foo' alert(e.data.text); // 'baa' } } });
Example
WebSocket Chat WebSocket Chat