Socket.IO: how can i get a socketid when i emit a specific client in socket.io 1.0
I want to communicate an action to a specific client using socket.io 1.0.
After reading Sending a message to a specific ID in Socket.IO 1.0 , I know I can Application:
io.sockets.connected[socketid].emit()
to convey the action to a specific person.
But how can I get it socketid
?
I wrote like this: socket.id=nickName
but it doesn't work.
+1
Tony chen
source
to share
1 answer
Just accessing an id
object property socket
:
io.on('connection', function(socket) {
console.log(socket.id);
});
+1
Oleg
source
to share