Advertisement
codeplanner

XSockets - Tracking connect/disconnect with JavaScript

Apr 7th, 2013
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.     <title></title>
  5.     <script src="Scripts/jquery-1.9.1.js"></script>
  6.     <script src="Scripts/jXSockets.2.3.js"></script>
  7.    
  8.     <script>
  9.  
  10.         var ws = null;
  11.  
  12.         $(function() {
  13.             ws = new XSockets.WebSocket('ws://127.0.0.1:4502/Generic');
  14.  
  15.             ws.bind(XSockets.Events.connection.onclientconnect, function (client) {
  16.                 console.log('A client connected',client);
  17.             });
  18.            
  19.             ws.bind(XSockets.Events.connection.onclientdisconnect, function (client) {
  20.                 console.log('A client disconnected', client);
  21.             });
  22.  
  23.             ws.bind(XSockets.Events.open, function(client) {
  24.                 console.log('You are connected',client);
  25.             });
  26.         });
  27.  
  28.     </script>
  29. </head>
  30. <body>
  31.  
  32. </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement