I am trying to emit to a particular socket ID:
socket(user[playID]).emit('correct', data);
But I'm getting:
TypeError: object is not a function
if I log out user[playID]
I do get a valid socket ID.
Appreciated!
Here is my setup in case I'm missing something:.
// Tell Socket.io to pay attention
servio = io.listen(server);
// Tell HTTP Server to begin listening for connections on port 3250
sock = server.listen(3250);
This should do it
servio.sockets.socket(id).emit('hello');
This answer covers the same/similar topic. In short, consider keeping a reference to the connected clients yourself and emit to them as desired, rather than relying on socket.io's internals, which could change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With