Repository navigation
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? |
Answered by
darrachequesne
Dec 30, 2020
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? |
0 replies
|
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. |
2 replies
Answer selected by
darrachequesne
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are several solutions, depending on your use case:
I think this is currently missing from the documentation, I will definitely add this.