fixed admin page active sockets

v1.18.x
Baris Soner Usakli 11 years ago
parent 16a42619b5
commit 1980e945da

@ -18,6 +18,13 @@ define(function() {
};
Admin.updateRoomUsage = function(err, data) {
function getUserCountIn(room) {
var count = 0;
for(var user in data[room]) {
++count;
}
return count;
}
var active_users = $('#active_users'),
total = 0;
@ -31,7 +38,7 @@ define(function() {
for (var room in data) {
if (room !== '') {
var count = $(data[room]).length;
var count = getUserCountIn(room);
total += count;
usersHtml += "<div class='alert alert-success'><strong>" + room + "</strong> " + count + " active user" + (count > 1 ? "s" : "") + "</div>";
}

@ -91,6 +91,9 @@ SocketMeta.rooms.enter = function(socket, data) {
if (data.leave && server.rooms[data.leave] && server.rooms[data.leave][socket.id] && data.enter !== data.leave) {
delete server.rooms[data.leave][socket.id];
if(!Object.keys(server.rooms[data.leave]).length) {
delete server.rooms[data.leave];
}
}
}

Loading…
Cancel
Save