Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. wss.on('connection', function(ws)
  2. {  
  3.     wssClients.push(ws);
  4.     wssClientCount++;
  5.     ws.send("Connected");
  6.     console.log("Websocket Connected");
  7.  
  8.     ws.on('message', function(message)
  9.     {
  10.         if (message == "status")
  11.         {
  12.             messageToSend = '{"action": "subscribe"}';
  13.  
  14.             wsClient.getClient().send(messageToSend)
  15.  
  16.             console.log("Status sent");
  17.         }
  18.         else
  19.         {
  20.             sendAll("system", message);
  21.         }
  22.     });
  23.  
  24.     ws.on('close', function(ws)
  25.     {
  26.         wssClients.splice(ws, 1);
  27.         wssClientCount--;
  28.         console.log("Websocket Closed");
  29.     });
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement