socket.io-php-emitter icon indicating copy to clipboard operation
socket.io-php-emitter copied to clipboard

Check if room exists/if anyone is in room

Open Especially opened this issue 9 years ago • 1 comments

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??

Especially avatar Oct 14 '15 17:10 Especially

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

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

amolmk avatar May 16 '17 10:05 amolmk