I have need to know the current socket ID and index of that socket for a given socket.emit()
and corresponding socket.on()
, but I could not find a good reference for how to do this in socket.io documentation.
For instance:
Client
socket.emit('myMessage', myVar);
Server
socket.on('myMessage', function(myVar){
//Need the socket id of the client who just emitted
//and whether or not they are the first socket, second socket, third socket, etc.
// e.g. something like:
currentSocketID = io.socket.connected[socketid]; //?? what is the correct syntax?
currentSocketIndex = io.socket.connected[index[i]]; //?? what is correct syntax?
});
via Dshiz
No comments:
Post a Comment