0

I know that if I emit data on a socket, the data would be emitted to the all connected clients.

io.emit("test", data)

For instance if I run the command above, actually the data reaches to the all clients. But only test channel listeners handle it.

To prevent that, I use rooms. I use code like the following:

io.in("test").emit(data)

So, what if a client send data to the server, then will data be reached to the all clients?

Note: I also use socket.io-redis to make cluster.

efkan
  • 12,991
  • 6
  • 73
  • 106

1 Answers1

0

This code will send to all client in "roomName"

io.to(roomName).emit('new msg', {data:'hello every clients'});

tuananh
  • 747
  • 8
  • 17