Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens with unhandled socket.io events?

Does socket.io ignore\drop them? The reason why Im asking this is the following. There is a client with several states. Each state has its own set of socket handlers. At different moments server notifies the client of state change and after that sends several state dependent messages. But! It takes some time for the client to change state and to set new handlers. In this case client can miss some msgs... because there are no handlers at the moment. If I understand correctly unhandled msgs are lost for client.

May be I miss the concept or do smth wrong... How to hanle this issues?

like image 576
Dmitry Isakov Avatar asked Feb 09 '23 23:02

Dmitry Isakov


1 Answers

Unhandled messages are just ignored. It's just like when an event occurs and there are no event listeners for that event. The socket receives the msg and doesn't find a handler for it so nothing happens with it.

You could avoid missing messages by always having the handlers installed and then deciding in the handlers (based on other state) whether to do anything with the message or not.

like image 191
jfriend00 Avatar answered Feb 11 '23 15:02

jfriend00