From afcb98a625f73f9b31a84e3bdd2597cfa4f52fba Mon Sep 17 00:00:00 2001 From: Mike McNeil Date: Fri, 12 Dec 2014 15:25:59 -0600 Subject: [PATCH] Implemented in-the-mean-time thing for https://github.com/Automattic/socket.io/issues/1908#issuecomment-66836641 --- lib/hooks/pubsub/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/hooks/pubsub/index.js b/lib/hooks/pubsub/index.js index 6b3110689..7bcfd6bb9 100644 --- a/lib/hooks/pubsub/index.js +++ b/lib/hooks/pubsub/index.js @@ -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'); } };