share the same socket.io channel among browser tabs
Hi,
It could be a dumb question, but i would like to get some help.
Let's suppose a browser opened with 100 tabs. In the current socket.io implementation, i think each tab would make its own connection with the server, and therefore 100 different socket.io channels would be generated.
Question: Is there any way to share the same socket.io channel among browser tabs which use the same (domain) cookie?
thanks in advance
You can't share one connection between different tabs in browser. It's a browser limitation, not a socket.io client. So, you can't use same socket.io channel for all tabs.
Not even if you could somehow authenticate with the same user id/session id ?
No. The tabs can't effectively pass messages between one another, and they aren't told when other tabs are closed.
Even if you solved that, your feature would require rearchitecting a lot of the client and the server. Its not worth fixing simply to make 100 tabs use less RAM.
https://www.npmjs.com/package/socketio-shared-webworker is a fork of socket.io that does exactly what is wanted here. Using the webworker it is able to have multiple tabs that can communicate between one another.