mardi 31 mars 2015

How to access the target socket in a Socket.io handler

I'm working with a Socket.io server and I'm trying to access the socket that emitted the event from the client.


There's this example in the docs :



socket.on('private message', function (from, msg)
{
console.log('I received a private message by ', from, ' saying ', msg);
});


Trying to use this, I've noticed that the parameter order has changed in the latest version and the 'from' parameter is actually a function.


I'm having trouble using this to get information about who emitted the event.


Is there another way? or perhaps a way using the parameter to get the info?


Aucun commentaire:

Enregistrer un commentaire