Answer the question
In order to leave comments, you need to log in
How to break websocket connection (Socket.IO + Redis + Laravel 5)?
There is a socket server: socketio + ioredis .
When the page loads, a connection to the server is created:
socket = io(socketURL);
socket.on('connect', function (user) {
socket.emit('join');
});
if (typeof socket != 'undefined') {
console.log('We must drop the connection (disconnect) :<');
socket.close();
}
socket = io(socketURL);
socket.on('connect', function (user) {
socket.emit('join');
});
socket.on('disconnect', function () {
socket.close();
return;
});
Answer the question
In order to leave comments, you need to log in
it seems to work
the code is not perfect, but I hope you get the idea
codepen.io/just-a-training/pen/NAXWxm/?editors=1100
It looks like all the blocks are the same width.
Decision. Redis hung
pmessage to catch events by pattern. In your case, it could just be message '
It looked like this:
redis.on('pmessage', function (pattern, channel, message) {
// some code
});
// вешаем событие не через .on, а через .addListener
// onPmessage - коллбэк, который вынесен в функцию, в этом же пространстве имен
redis.addListener('pmessage', onPmessage);
socket.on('disconnect', function () {
redis.removeListener('pmessage', onPmessage);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question