Reputation: 3272
I'm looking for a way to handle the socket.io connections on my nodeJs server.
Calling once socket.connect('server-addr')
of a client, makes the socket.io server save, each time the client connects, a new reference in io.sockets.clients()
. It doesn't check if the client is already in the list. It just puts it as a new client into the list.
How can I avoid the server to save the same client in new client-objects after each connection?
Upvotes: 0
Views: 1931
Reputation: 3718
You can use sessionID that come with client to distinguish between different clients. If you don't know how to use sessions you can follow this link: http://www.danielbaulig.de/socket-ioexpress/. This link explains how to extract session id in sockets using express
Upvotes: 1