I'm having some problems with socket.io, and I have no idea how to solve it. I've an app with a login system with socket.io to manage user interactions. Also I've an array to manage all active websocket sessions. This array stores a pair session.id => username.
Problems begin when a user opens a new tab with the same page (or a different page that uses the websocket). This cause a duplicate username entry in the array.
{id1, username}
{id2, username}
When socket sends a message to the user, it sends only to the first session id of the array, so only one tab receives the message.
I've tried to change the socket id of the new connection to match the other, but it doesn't work.
socket.id = sessionId of the other websocket;
I think another solution is to send the message to all the open sessions, but I think it's not the best way to do that.
Thanks.