|
|
@ -76,6 +76,7 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|
|
|
|
|
|
|
|
|
|
|
if(userSockets[uid].length === 0) {
|
|
|
|
if(userSockets[uid].length === 0) {
|
|
|
|
delete users[sessionID];
|
|
|
|
delete users[sessionID];
|
|
|
|
|
|
|
|
emitOnlineUserCount();
|
|
|
|
if(uid) {
|
|
|
|
if(uid) {
|
|
|
|
io.sockets.in('global').emit('api:user.isOnline', isUserOnline(uid));
|
|
|
|
io.sockets.in('global').emit('api:user.isOnline', isUserOnline(uid));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -410,8 +411,17 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function emitOnlineUserCount() {
|
|
|
|
|
|
|
|
var online = Object.keys(users);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var returnObj = {
|
|
|
|
|
|
|
|
users: online.length
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
io.sockets.emit('api:user.active.get', returnObj)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('api:user.active.get', function() {
|
|
|
|
socket.on('api:user.active.get', function() {
|
|
|
|
user.active.get();
|
|
|
|
emitOnlineUserCount();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('api:posts.favourite', function(data) {
|
|
|
|
socket.on('api:posts.favourite', function(data) {
|
|
|
@ -422,10 +432,6 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|
|
|
favourites.unfavourite(data.pid, data.room_id, uid, socket);
|
|
|
|
favourites.unfavourite(data.pid, data.room_id, uid, socket);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('api:user.active.get_record', function() {
|
|
|
|
|
|
|
|
user.active.get_record(socket);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('api:topic.delete', function(data) {
|
|
|
|
socket.on('api:topic.delete', function(data) {
|
|
|
|
threadTools.delete(data.tid, uid, function(err) {
|
|
|
|
threadTools.delete(data.tid, uid, function(err) {
|
|
|
|
if (!err) {
|
|
|
|
if (!err) {
|
|
|
|