From 6cb5f9c0981ac56374195dd79eb2ff95ccd5137e Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 17 Oct 2014 18:46:17 -0400 Subject: [PATCH] emit stats to registered users only --- src/socket.io/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/socket.io/index.js b/src/socket.io/index.js index 3f456df2fe..36ebed87db 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -178,12 +178,11 @@ Sockets.init = function(server) { var socketCount = Sockets.getUserSocketCount(uid); if (uid && socketCount <= 1) { socket.broadcast.emit('event:user_status_change', {uid: uid, status: 'offline'}); + emitOnlineUserCount(); } onUserDisconnect(uid, socket.id, socketCount); - emitOnlineUserCount(); - for(var roomName in io.sockets.manager.roomClients[socket.id]) { if (roomName.indexOf('topic') !== -1) { io.sockets.in(roomName.slice(1)).emit('event:user_leave', socket.uid); @@ -430,7 +429,7 @@ function emitTopicPostStats(callback) { }; if (!callback) { - io.sockets.emit('meta.getUsageStats', null, stats); + io.sockets.in('online_users').emit('meta.getUsageStats', null, stats); } else { callback(null, stats); } @@ -450,7 +449,7 @@ function emitOnlineUserCount(callback) { if (callback) { callback(null, returnObj); } else { - io.sockets.emit('user.getActiveUsers', null, returnObj); + io.sockets.in('online_users').emit('user.getActiveUsers', null, returnObj); } }