in socket.io
, if I have a room abc
, it there a way of knowing if anyone is in the room, for example, getting an array of sockets that have joined
a room?
for example, in fantasy football. admin input changes the Payton Manning
record in the database. a table trigger sees the change his status, so Postgres
sends a notification to the node.js
app. on being notified at the app level, we wish to display Manning's stats to anyone who has drafted Manning and is online, that is, in the Peyton Manning
room.
if no one is in the room, do not wish to do the database query, since it's pretty expensive. otherwise will do query the db and send the stats to everyone in the room.
Thats what im doing in my chat app
var sockets = io.sockets.clients(channel); /*channel = room*/