How to turn-off event sending after reconnection? #3729
-
I would like to send non-volatile (thus "normal") events, but I'd like to turn off the "remember events and send them after reconnection" behaviour. How is it possible to achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
So far what seems to be working is to keep a this.connected variable and set it to false in a socket.on('disconnect') event. Then wrap every emit in a From my experimentation it seems that:
Can someone confirm this is the right logic to do this? |
Beta Was this translation helpful? Give feedback.
-
There are several solutions, depending on your use case:
if (socket.connected) {
socket.emit( /* ... */ );
} else {
// ...
}
socket.on("connect", () => {
socket.sendBuffer = [];
});
socket.volatile.emit( /* ... */ ); I think this is currently missing from the documentation, I will definitely add this. |
Beta Was this translation helpful? Give feedback.
There are several solutions, depending on your use case:
I think this is currently missing from the documentation, I will definitely add this.