SocketCluster / socketcluster-client

JavaScript client for SocketCluster
MIT License
292 stars 91 forks source link

Reuse connection instance #27

Closed mattkrick closed 8 years ago

mattkrick commented 8 years ago

Each call to connect() creates a new connection. If I call this from different components, I'll end up with a bunch of different connections, each with their own subs. Socket.io handles this with a manager & allows for multiplexing.

In socket.io:

s1 = socketIO.connect();
s2 = socketIO.connect();
s1 === s2 //true

Would is be possible to do the same with SC?

jondubois commented 8 years ago

Right now you have to make sure you pass around the same socket object to all components which want to share it.

I think we could implement multiplexing functionality. We also should have an option to set multiplex to false just like in Socket.io. A pull request would be welcome.