|
|
@ -131,6 +131,7 @@ Sockets.init = function(server) {
|
|
|
|
emitOnlineUserCount();
|
|
|
|
emitOnlineUserCount();
|
|
|
|
|
|
|
|
|
|
|
|
for(var roomName in io.sockets.manager.roomClients[socket.id]) {
|
|
|
|
for(var roomName in io.sockets.manager.roomClients[socket.id]) {
|
|
|
|
|
|
|
|
console.log('disconnected from', roomName);
|
|
|
|
updateRoomBrowsingText(roomName.slice(1));
|
|
|
|
updateRoomBrowsingText(roomName.slice(1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -235,7 +236,11 @@ function isUserOnline(uid) {
|
|
|
|
Sockets.updateRoomBrowsingText = updateRoomBrowsingText;
|
|
|
|
Sockets.updateRoomBrowsingText = updateRoomBrowsingText;
|
|
|
|
function updateRoomBrowsingText(roomName) {
|
|
|
|
function updateRoomBrowsingText(roomName) {
|
|
|
|
|
|
|
|
|
|
|
|
function getUidsInRoom(room) {
|
|
|
|
if (!roomName) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getUidsInRoom() {
|
|
|
|
var uids = [];
|
|
|
|
var uids = [];
|
|
|
|
var clients = io.sockets.clients(roomName);
|
|
|
|
var clients = io.sockets.clients(roomName);
|
|
|
|
for(var i=0; i<clients.length; ++i) {
|
|
|
|
for(var i=0; i<clients.length; ++i) {
|
|
|
@ -246,7 +251,7 @@ function updateRoomBrowsingText(roomName) {
|
|
|
|
return uids;
|
|
|
|
return uids;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getAnonymousCount(roomName) {
|
|
|
|
function getAnonymousCount() {
|
|
|
|
var clients = io.sockets.clients(roomName);
|
|
|
|
var clients = io.sockets.clients(roomName);
|
|
|
|
var anonCount = 0;
|
|
|
|
var anonCount = 0;
|
|
|
|
|
|
|
|
|
|
|
@ -258,15 +263,17 @@ function updateRoomBrowsingText(roomName) {
|
|
|
|
return anonCount;
|
|
|
|
return anonCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var uids = getUidsInRoom(roomName),
|
|
|
|
var uids = getUidsInRoom(),
|
|
|
|
anonymousCount = getAnonymousCount(roomName);
|
|
|
|
anonymousCount = getAnonymousCount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture', 'status'], function(err, users) {
|
|
|
|
user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture', 'status'], function(err, users) {
|
|
|
|
if(!err) {
|
|
|
|
if(!err) {
|
|
|
|
users = users.filter(function(user) {
|
|
|
|
users = users.filter(function(user) {
|
|
|
|
return user.status !== 'offline';
|
|
|
|
return user.status !== 'offline';
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log('['+roomName+']', users.length, anonymousCount);
|
|
|
|
io.sockets.in(roomName).emit('get_users_in_room', {
|
|
|
|
io.sockets.in(roomName).emit('get_users_in_room', {
|
|
|
|
users: users,
|
|
|
|
users: users,
|
|
|
|
anonymousCount: anonymousCount,
|
|
|
|
anonymousCount: anonymousCount,
|
|
|
|