Returns the presence roster for a channel — a flat built-in accessor parallel to wsPublish. The roster is a struct keyed by presence key, each value holding a metas array of the tracked metadata for that key (for example, a user's multiple tabs or devices). The channel argument is optional inside a channel handler, where it defaults to the current channel. Returns an empty struct when there is no registry or channel.
wsPresence( [ channel ] )
→ returns struct
Get everyone currently tracking presence on a channel.
var roster = wsPresence( "/chat" );
writeDump( roster );
Expected Result: { "user-42": { metas: [ { user: "user-42", status: "online" } ] }, "user-99": { metas: [ { user: "user-99", status: "away" } ] } }
Inside a channel handler, wsPresence() with no argument reads the current channel's roster.
function whoami( socket, data ) on="whoami" secured {
return io().presence(); // equivalent to wsPresence() here
}
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.