socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

v4 RemoteSocket unsupport to/in function

Open txone opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe. v4 RemoteSocket unsupport to/in function send to everyone in the room except sender when use the controller(KOA or exressjs) ,

Describe the solution you'd like RemoteSocket support to/in function .

txone avatar Mar 25 '21 01:03 txone

I'm in the same situation. 🤔 I surfed across the code and the only thing would be to be able to somehow tell other servers to search for the socket with a given ID and not emit the message to it.

rennokki avatar Apr 21 '21 18:04 rennokki

I think you should be able to achieve what you want with except():

io.except(socket.id).emit(/* ... */);

io.to("room1").except(socket.id).emit(/* ... */);

Documentation: https://socket.io/docs/v4/server-api/#namespace-except-rooms

darrachequesne avatar Apr 23 '21 21:04 darrachequesne