Closed
Description
I make a simple example for socket.io. when the client emits the 'disconnect' event, the server side would execute socket.on('disconnect', function(msg) too many times that the server would break down because of ' socket.disconnect(socket.id); '
If I comment that line, there is no errors, so what is the problem ?
code:
var app = require('express').createServer();
var redis = require('redis');
app.listen(3000);
var io = require('socket.io').listen(app);
io.sockets.on('connection',function(socket){
console.log("Client has connected id: "+socket.id+" ");
socket.emit('news',{hello:'world'});
socket.on('disconnect', function(msg)
{
console.log("Client has disconnected id: "+socket.id+" ");
socket.disconnect(socket.id);
}) ;
});
Metadata
Metadata
Assignees
Labels
No labels