Pampour

Socket.IO Request & Response

Dec 28th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. SOCKET.IO SOCKET INFORMATION
  2. http://stackoverflow.com/questions/10058226/send-response-to-all-clients-except-sender-socket-io
  3.  
  4. // send to current request socket client
  5. socket.emit('message', "this is a test");
  6.  
  7. // sending to all clients, include sender
  8. io.sockets.emit('message', "this is a test");
  9.  
  10. // sending to all clients except sender
  11. socket.broadcast.emit('message', "this is a test");
  12.  
  13. // sending to all clients in 'game' room(channel) except sender
  14. socket.broadcast.to('game').emit('message', 'nice game');
  15.  
  16. // sending to all clients in 'game' room(channel), include sender
  17. io.sockets.in('game').emit('message', 'cool game');
  18.  
  19. // sending to individual socketid
  20. io.sockets.socket(socketid).emit('message', 'for your eyes only');
Advertisement
Add Comment
Please, Sign In to add comment