Skip to content
Closed
Show file tree
Hide file tree
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
25 changes: 24 additions & 1 deletion lib/adapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Module dependencies.
*/
Expand Down Expand Up @@ -120,3 +119,27 @@ Adapter.prototype.broadcast = function(packet, opts){
}
}
};

/**
* Gets all sockets in a room.
*
* Options:
* - `room` {String} room name
*
* @api public
*/

Adapter.prototype.clients = function(room){
var sockets = [];

var room = this.rooms[room];
if (room){
for (var id in room)
{
sockets.push(this.nsp.connected[id]);
}
}

return sockets;

};
14 changes: 13 additions & 1 deletion lib/namespace.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Module dependencies.
*/
Expand Down Expand Up @@ -224,3 +223,16 @@ Namespace.prototype.write = function(){
this.emit.apply(this, args);
return this;
};

/**
* Gets all sockets in a room.
*
* Options:
* - `room` {String} room name
*
* @api public
*/

Namespace.prototype.clients = function(room){
return this.adapter.clients(room);
};