Sorry for the late reply, but it appeared a couple of times in # sails.js
I don't know if my path is correct, but it works with 0.9.4, and this is the best way I've found so far:
// if sails is undefined, get it out of global var sails = global.sails, ws = sails.ws, channel = req.param('channel') || '', // by room, or '' for top level current = ws.of(channel).manager.open; // an array of socket ids
If you do not use ws , then sails.io works (the structure is slightly different from tho.) Call current.length to get the number of connected clients, or you can do something like:
var status = []; for (var x in current) { if (ws.of(channel).manager.handshaken.hasOwnProperty(x)) { status.push(ws.of(channel).manager.handshaken[x].session.user); } }
- to find out who they are. :) hth
source share