Answer the question
In order to leave comments, you need to log in
What is the correct way to resubscribe to a socket to protect against breaks?
I use the socketIo
library .
This is how I connect to the socket and listen:
socketIo.emit('subscribe', 'message');
socketIo.on('message', function (data) {
//
});
socketIo.on('connect', function (data) {
socketIo.emit('subscribe', 'message');
});
socketIo.emit('subscribe', 'message');
socketIo.on('message', function (data) {
//
});
Answer the question
In order to leave comments, you need to log in
Make a wrapper and add your "crutch". SocketIO (like sockjs) does not offer such a solution out of the box, so everyone adds on as needed.
Maybe so?
socketIo.on('disconnect', function () {
socketIo.on('connect', function (data) {
socketIo.emit('subscribe', 'message');
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question