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

Check if room exists/if anyone is in room #18

Open
Especially opened this issue Oct 14, 2015 · 1 comment
Open

Check if room exists/if anyone is in room #18

Especially opened this issue Oct 14, 2015 · 1 comment

Comments

@Especially
Copy link

Is there a way to check whether or not a room exists before using emitter->to(room)->emit()? If there's no one in room then i'd like PHP to execute a different script, is there any way to handle this??

@amolmk
Copy link

amolmk commented May 16, 2017

You can simply check like this
socketio.sockets.adapter.rooms[roomId]

This returns you a object with sId e.g.
{"1sEAEIZeuMgdhF35AAAA":true}

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

2 participants