Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does socket.io queue messages to disconnected clients?

If a client socket disconnected during the middle of a multiplayer game. Does socket.io queue events that are emitted by the server after the has client disconnected?

If so this would mean that when the client socket reconnected, it would be updated with all the events which the server tried to emit to if while it was disconnected.

like image 204
therewillbecode Avatar asked Oct 17 '22 06:10

therewillbecode


1 Answers

No, you would need some sort of data structure on the server-side that holds a record of whatever data the client needs, then be able to update the client if they connect again. When a user disconnects from Socket.io then connects again, the socket ID is never the same, so you need some sort of unique identifier that can let the server know which client is who (i.e. username, userID, etc)

like image 175
Retro Gamer Avatar answered Nov 15 '22 12:11

Retro Gamer