Skip to content

Commit

Permalink
Implemented in-the-mean-time thing for socketio/socket.io#1908 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil committed Dec 12, 2014
1 parent 3c985cf commit afcb98a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/hooks/pubsub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,18 @@ module.exports = function(sails) {
* @return {array} An array of socket ID strings
*/
sails.sockets.subscribers = function(roomName, returnSockets) {

// The underlying implementation was changed a bit with the upgrade
// to Socket.io v1.0. For more information, see:
// •-> https://github.com/Automattic/socket.io/issues/1908#issuecomment-66836641
// and •-> https://github.com/Automattic/socket.io/pull/1630#issuecomment-64389524

if (returnSockets) {
return sails.io.sockets.clients(roomName);
return sails.io.nsps['/'].adapter.rooms[roomName];
// return sails.io.sockets.clients(roomName);
} else {
return _.pluck(sails.io.sockets.clients(roomName), 'id');
return _.keys(sails.io.nsps['/'].adapter.rooms[roomName]);
// return _.pluck(sails.io.sockets.clients(roomName), 'id');
}
};

Expand Down

0 comments on commit afcb98a

Please sign in to comment.