Reputation: 1405
I am developing an application in nodeJS which uses socket.io for interactive gameplay. Inside the socket.on('connection') callback block, I have declared several variables. From what I can tell, these variables are connection-specific and there will be an instance for each callback fired on a socket connection for each client.
During my tests, I tried in two browsers and was able to play two independent game sessions at the same time which lead me to confirm this view of those variables.
However, when in a more live environment, I was noticing other players actions appearing as actions on my screen. I don't use broadcast anywhere, just simple emits inside the connection block, so I am perplexed why I see this happening.
Is my assumption about connection-specific variables incorrect? Or is there a more subtle application-specific reason this might be happening?
Upvotes: 3
Views: 865
Reputation: 876
Your assumption is correct - the variables are local to the per-socket connection event. There is something else going on which is causing you issues.
Upvotes: 1