question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

io.sockets.socket(socketId) is gone?

See original GitHub issue

In the 0.9.x, we can use io.sockets.socket(socketId), but in 1.0.x, it’s gone. How to find a socket by id in 1.0.x?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
victorwoocommented, Jun 16, 2014

Thank you @rsdrsd , io.to(socket.id).emit() is what I want. I think the official docs didn’t introduce this io.to(socketId) method clearly.

8reactions
StefansAryacommented, Jul 2, 2017

@darrachequesne Thanks for the explanation, I have learn so many things with nodejs REPL and found that I can do this for the alternative… I’ll leave this here if someone have a same problem like me… io.sockets.sockets[targetSocketID].join(roomID)

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - How to get the socket id when parsing through io ...
As of socket.io v3, io.sockets is now a Map object as shown here. You can iterate it directly with: for (let [id, socket]...
Read more >
Server API - Socket.IO
A reference to the underlying Engine.IO server. See here. server.sockets​. <Namespace>. An alias for the main namespace ( / ).
Read more >
How to manage users in socket.io in Node.js ? - GeeksforGeeks
Approach: First, it is important to note that when a new socket is created, it is assigned a unique Id which is retrieved...
Read more >
Impossible to get socket.io from a Express route
io.sockets.socket(socket.id).emit('formPost', { success: true, msg: 'You win!'} ); ... There's a great blog post on the wiki that goes into greater depth
Read more >
Socket.IO - Quick Guide - Tutorialspoint
It involves polling the server for changes, keeping track of timestamps, and it is a lot slower than it should be. Sockets have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found