fixed topics bug that was prevent /latest /popular /active and subsequently the admin versions of those routes from working. removed debug statements. added admin socket room. added dynamic updating of active users on acp index

This commit is contained in:
psychobunny
2013-05-09 04:11:16 +00:00
parent 30323fa29f
commit 09c9d0ee1f
5 changed files with 9 additions and 4 deletions

View File

@@ -182,6 +182,7 @@ var socket,
app.current_room = null; app.current_room = null;
app.enter_room = function(room) { app.enter_room = function(room) {
console.log(room)
if (app.current_room === room) return; if (app.current_room === room) return;
socket.emit('event:enter_room', { socket.emit('event:enter_room', {

View File

@@ -24,6 +24,7 @@
}, false); }, false);
}); });
}()) }())
</script> </script>

View File

@@ -26,17 +26,19 @@
socket.on('api:get_all_rooms', function(data) { socket.on('api:get_all_rooms', function(data) {
var active_users = document.getElementById('active_users'), var active_users = document.getElementById('active_users'),
total = 0; total = 0;
active_users.innerHTML = '';
for(var room in data) { for(var room in data) {
if (room !== '') { if (room !== '') {
var count = data[room].length; var count = data[room].length;
total += count; total += count;
active_users.innerHTML = active_users.innerHTML + "<div class='alert alert-success'><strong>" + room + "</strong> " + count + " active user" + (count > 1 ? "s" : "") + "</div><br />"; active_users.innerHTML = active_users.innerHTML + "<div class='alert alert-success'><strong>" + room + "</strong> " + count + " active user" + (count > 1 ? "s" : "") + "</div>";
} }
} }
document.getElementById('connections').innerHTML = total; document.getElementById('connections').innerHTML = total;
}); });
app.enter_room('admin');
socket.emit('api:get_all_rooms'); socket.emit('api:get_all_rooms');
</script> </script>

View File

@@ -140,7 +140,7 @@ var RDB = require('./redis.js'),
// Global Topics // Global Topics
if (uid == null) uid = 0; if (uid == null) uid = 0;
if (uid !== null) { if (uid !== null) {
RDB.lpush('topics:tid', tid); RDB.db.sadd('topics:tid', tid);
} else { } else {
// need to add some unique key sent by client so we can update this with the real uid later // need to add some unique key sent by client so we can update this with the real uid later
RDB.lpush('topics:queued:tid', tid); RDB.lpush('topics:queued:tid', tid);

View File

@@ -66,7 +66,6 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
}); });
socket.on('api:get_all_rooms', function(data) { socket.on('api:get_all_rooms', function(data) {
console.log('recieve');
socket.emit('api:get_all_rooms', io.sockets.manager.rooms); socket.emit('api:get_all_rooms', io.sockets.manager.rooms);
}) })
@@ -102,6 +101,8 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
}); });
}); });
if (data.enter != 'admin') io.sockets.in('admin').emit('api:get_all_rooms', io.sockets.manager.rooms);
}); });
// BEGIN: API calls (todo: organize) // BEGIN: API calls (todo: organize)