Skip to content
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

List clients in a room? #1506

Closed
inca opened this issue Apr 30, 2014 · 5 comments
Closed

List clients in a room? #1506

inca opened this issue Apr 30, 2014 · 5 comments

Comments

@inca
Copy link

inca commented Apr 30, 2014

In 0.9.x we had a nice method .clients. Is there any equivalent in 1.0?

@t3chnoboy
Copy link

Duplicate of issue #1450
Also check out this PR #1428

@ismarslomic
Copy link

Duplicate #1544

@inca inca closed this as completed May 30, 2014
@ChristopherHButler
Copy link

Can this be re-opened for version 4?

@darrachequesne
Copy link
Member

@ChristopherHButler you can use the fetchSockets() method, which has been added in Socket.IO v4.0.0:

// return all Socket instances
const sockets = await io.fetchSockets();

// return all Socket instances in the "room1" room of the main namespace
const sockets = await io.in("room1").fetchSockets();

// return all Socket instances in the "room1" room of the "admin" namespace
const sockets = await io.of("/admin").in("room1").fetchSockets();

// this also works with a single socket ID
const sockets = await io.in(theSocketId).fetchSockets();

Documentation: https://socket.io/docs/v4/server-instance/#Utility-methods

@ChristopherHButler
Copy link

Perfect, thank you @darrachequesne !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants