Skip to content

How to turn-off event sending after reconnection? #3729

Answered by darrachequesne
hyperknot asked this question in Q&A
Discussion options

You must be logged in to vote

There are several solutions, depending on your use case:

  • use the connected attribute (as you suggested)
if (socket.connected) {
  socket.emit( /* ... */ );
} else {
  // ...
}
  • empty the internal buffer upon connection
socket.on("connect", () => {
  socket.sendBuffer = [];
});
socket.volatile.emit( /* ... */ );

I think this is currently missing from the documentation, I will definitely add this.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@hyperknot
Comment options

@darrachequesne
Comment options

Answer selected by darrachequesne
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants