-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get all clients in a room across all nodes #109
Conversation
can i safely use |
Also, this is incompatible with socket.io 1.3.7, as
|
@artofspeed, socket.rooms is not implemented although it would not require a lot of work. Regarding the incompatibility with v1.3.7, you can access this function via
If you need a |
Is there any intentions soon by the maintainer to implement this PR? is a great feature that I guess a lot of people is wanting as me. |
+1 this is a really lacking feature in current implementation |
Hi @fgodino ! Thanks for your PR. I'll try to test that ASAP. Is anybody already using it? Any shortcomings? |
Hey @darrachequesne, we are already using it in our website https://www.varsityviews.com/collections/ and no problems so far. |
Hey @fgodino, Any solution? |
try { | ||
var decoded = JSON.parse(msg); | ||
} catch(err){ | ||
self.emit('error', err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: self
seems undefined here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@artofspeed a socket should only be connected to one node at a time, so Besides, I think |
@fgodino thanks a lot! |
@darrachequesne np! |
the funny thing is: if a user opens multiple tabs and go to different rooms in multiple tabs it might get a different socket.id in each of the connections and then you might not be able to know all the different socket.ids represent the same user? Does that make sense on your application context? On my app every time a user logs in ( for instance using facebook or chrome ) i have to save his socket.id to the database, then if the user open another tab he will have two socket.id ( one in each tab ) and things start to get a bit complicated... It's manageable, but not exactly "programmer friendly".. Am i doing something wrong? It sounds like there must be an easier way. |
@hems Managing users (and not sockets) is out of the scope of that library (what is a user is very much context-dependant) Nonetheless, couldn't you create a room dedicated to each user, and make every socket join that room once authenticated? |
@darrachequesne yeah it makes sense. Still i have to keep a list of socket.ids a logged user has so when retrieving the list of users from a room i can find the user profile on my database and display for instance his name/avatar. |
@darrachequesne @fgodino is it possible to get all rooms a socket has joined, given the |
This pull request adds the ability to get all clients IDs connected to a room or rooms. It's up to date with
Adapter
so a call to Namespace#clients(fn:Function) will return the same result asRedisAdapter.clients(rooms:Array, fn:Function)