Nodejs Events On('connect') Error
Recently I have started learning Node.js with 'Node.js in Action' book. In chapter there is following listing: var events = require('events'); var net = require('net'); var channe
Solution 1:
I have solved my problem by the help of this SO question:
on the server side, the socket is already connected when you get the callback, and the event you're trying to listen to isn't emitted on an already connected socket.
So, I emitted 'join' outside of client.on('connect'). In other words this code:
client.on('connect', function () {
channel.emit('join', id, client);
});
does nothing. And it must be replaced by:
channel.emit('join', id, client);
Post a Comment for "Nodejs Events On('connect') Error"