Tuesday, 4 April 2017

How to send data from client to only socket server

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.



via efkan

No comments:

Post a Comment