Send response to all clients except sender

To send something to all clients, you use:

io.sockets.emit('response', data);

To receive from clients, you use:

socket.on('cursor', function(data) {
  ...
});

How can I combine the two so that when recieving a message on the server from a client, I send that message to all users except the one sending the message?

socket.on('cursor', function(data) {
  io.sockets.emit('response', data);
});

Do I have to hack it around by sending the client-id with the message and then checking on the client-side or is there an easier way?

12 Answers
12

Leave a Comment