Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add clientRooms method
That method returns the list of rooms a given socket has joined. It is
intended to be used by other adapters, without them needing to access
the innards of the adapter.
  • Loading branch information
darrachequesne committed Nov 20, 2016
commit 929e92578a035f4d0349c4c6c274e018a8fdf214
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Adapter.prototype.broadcast = function(packet, opts){
* Gets a list of clients by sid.
*
* @param {Array} explicit set of rooms to check.
* @param {Function} callback
* @api public
*/

Expand Down Expand Up @@ -195,6 +196,18 @@ Adapter.prototype.clients = function(rooms, fn){
if (fn) process.nextTick(fn.bind(null, null, sids));
};

/**
* Gets the list of rooms a given client has joined.
*
* @param {String} socket id
* @param {Function} callback
* @api public
*/
Adapter.prototype.clientRooms = function(id, fn){
var rooms = this.sids[id];
if (fn) process.nextTick(fn.bind(null, null, rooms ? Object.keys(rooms) : null));
};

/**
* Room constructor.
*
Expand Down