home / srv_push (navigation links) .

Server Push | Xat Links | End

Server Push


Amunt! Top Amunt!
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


Amunt! Top Amunt!
Xat

To run it, do

  1. {rh v6} npm install websocket
  2. posar frontend.js i frontend.html al directori del Apache : cp frontend.* /var/www/html/sxat/.
  3. {rhv6} /home/sebas/node/xat/node chat-server.js
  4. browser http://9.137.164.32/sxat/frontend.html

Tutorial, git, front end

[root@rhv6-64b xat]# node chat-server.js Wed May 06 2015 14:35:13 GMT+0200 (CEST) Server is listening on port 1337 Wed May 06 2015 14:35:16 GMT+0200 (CEST) Connection from origin http://9.137.164.32. Wed May 06 2015 14:35:16 GMT+0200 (CEST) Connection accepted. Wed May 06 2015 14:35:22 GMT+0200 (CEST) User is known as: pepet with magenta color. Wed May 06 2015 14:36:06 GMT+0200 (CEST) Received Message from pepet: hi Wed May 06 2015 14:41:43 GMT+0200 (CEST) Connection from origin http://9.137.164.32. Wed May 06 2015 14:41:43 GMT+0200 (CEST) Connection accepted. Wed May 06 2015 14:41:54 GMT+0200 (CEST) User is known as: er'paco with blue color. Wed May 06 2015 14:41:56 GMT+0200 (CEST) Received Message from er'paco: hola! Wed May 06 2015 14:42:05 GMT+0200 (CEST) Received Message from pepet: hola PACO

Amunt! Top Amunt!
Links

Ep ! Site under construction. Escriu-me !
Updated 20150526 (a)  
Uf !