Game server with private sockets #973
-
Hi! There is a game that has
The problem with this solution is that when the player reloads the page, the player's sid changes, then you need to get the rooms of the old sid and make Questions:
P.S I will be grateful for any help in these matters! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The To get the rooms a client is in, use the rooms() method. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer! Do I right get your take, I need to pass the user ID into the enter_room function instead of sid like |
Beta Was this translation helpful? Give feedback.
The
sid
is not great to be used as user identification, because as you well noticed, it changes when there is a reconnection (not only due to a refresh, but also due to network problems outside of the user's control). What you need to do is map thesid
to your own user ID in the connect handler, then use your own user IDs when you map to your game entities. Then if you receive a reconnection you can update your user ID to the newsid
value.To get the rooms a client is in, use the rooms() method.