WebSockets is a solution for real-time (low latency) interaction with JavaScript in a browser. There are backups to provide the WebSocket Flash API.
You can use JavaScript on the server and use something like http://RingoJs.org , which has connectors for WebSockets. If you use these two, you will get the following:
// SERVER websocket.addWebSocket(context, "/websocket", function(socket) { socket.onmessage = function(m) { // message m recieved from server }; socket.send('my message to the client'); }); // CLIENT var ws = new WebSocket("ws://localhost/websocket"); ws.onMessage(function(m) { // message m recieved from server // do something with it return; }); ws.send('message to server');
oberhamsi
source share