Reputation: 4238
I'm building an application in real time with socket.io
Each time the user enters the application creates a socket ID. So if I joining the application in several browser tabs generates me a socket id for each tab.
I generate a room for specific users and included my sockets id, but I need to emit broadcast message except to my sockets id.
This code don't work for me because emit broadcast message but sends to my other id sockets
socket.broadcast.to("room").emit('message', "somethings")
Any ideas?
Upvotes: 0
Views: 389
Reputation: 27855
Assuming you are using some application framework like express along side socket.io, you can use the valid session id obtained from Express.js for maping the socketIDs generated from the same session.
Other than maping the socketIDs to the sessionID, I dont think there is a way to obtain all the socketIDs generated across tabs as the information on other tabs wont be accessible in the current tab context.
Below are few existing questions discussing this same case:
Upvotes: 0