Server Push
Polling and
jQuery
Code Google FAQ,
webSockets plugin for jQuery
Think of Socket.IO as the jQuery of HTML5 WebSockets.
No two browser vendors will implement the WebSockets protocol exactly alike.
Socket.IO tries to normalize those differences.
.--------. .----------.
| | | |
| user | <-----------> | server |
| client | | |
| | | |
.--------. .----------.
^
.-------------. |
| | |
| admin | --------------.
| client |
| |
| <do push> |
| |
.-------------.
Two ways to implement it :
Exemple minim
HTML file:
<html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
var socket = new WebSocket( 'ws://localhost:8181/websession' ) ;
socket.onopen = function() {
alert( 'handshake successfully established. May send data now...' ) ;
};
socket.onclose = function() {
alert( 'connection closed' ) ;
};
</script>
</head>
<body>
</body>
</html>
Nice demos
https://www.websocket.org/demos.html