I'm pretty new here. I'm trying to use the emit function in this case with no luck :(.
Server Side:
socket.on('newUser', function(msg){ ConnectedSockets ++; var player; player = new Player(); player.CreatePlayer(msg.id, msg.name, msg.status); socket.id=msg.id; socket.name=msg.name; sockets[socket.id] = socket; for(i in sockets){ var myVar=sockets[i].name; socket.emit('listing',{name: myVar} ); } }) ; Client Side:
socket.on('listing', function(msg){ $('#list').val($('#list').val() + "\n"+msg.name); }) ; When I send newUser event on node.js console, no messages appear in response. If I write sys.puts("socket name:"+ myVar) in the for cycle, all the socket names appear as I expected.
Why the client doesn't receive any answer (no error message or any kind of warning)? :)