retrieve a socket connection directly using its socketID with O(1) time complexity #4918
Unanswered
jamie0xgitc0decat
asked this question in
Q&A
Replies: 1 comment
-
Hi! Yes, you can use the following method: const socket = io.of("/").sockets.get(theSocketId); This won't work within a cluster though, as the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am currently exploring the capabilities of Socket.IO and have a question regarding the efficiency of socket retrieval. Specifically, is it possible to retrieve a socket connection directly using its socketID with O(1) time complexity?
I am aware of the existing io.fetchSockets() method, which retrieves a list of all connected sockets. However, this approach seems less efficient for scenarios where direct access to a specific socket is required.
Any insights or guidance on whether Socket.IO supports a more direct and efficient method for socket retrieval would be greatly appreciated.
Thank you for your assistance.
Beta Was this translation helpful? Give feedback.
All reactions