removed getUserSockets

v1.18.x
barisusakli 10 years ago
parent fa92eb4d5c
commit 0a2d543186

@ -246,10 +246,10 @@
}
function logout(req, res) {
if (req.user && parseInt(req.user.uid, 10) > 0) {
if (req.user && parseInt(req.user.uid, 10) > 0 && req.sessionID) {
require('../socket.io').logoutUser(req.user.uid);
db.sessionStore.destroy(req.sessionID);
req.logout();
}

@ -216,14 +216,7 @@ function callMethod(method, socket, params, callback) {
}
Sockets.logoutUser = function(uid) {
Sockets.getUserSockets(uid).forEach(function(socket) {
if (socket.handshake && socket.handshake.signedCookies && socket.handshake.signedCookies['express.sid']) {
db.sessionStore.destroy(socket.handshake.signedCookies['express.sid']);
}
socket.emit('event:disconnect');
socket.disconnect();
});
io.sockets.in('uid_' + uid).emit('event:disconnect');
};
Sockets.in = function(room) {
@ -254,25 +247,6 @@ Sockets.getOnlineAnonCount = function () {
return Array.isArray(guestSocketIds) ? guestSocketIds.length : 0;
};
Sockets.getUserSockets = function(uid) {
// TODO: doesn't work in cluster
var userSocketIds = Object.keys(io.sockets.adapter.rooms['uid_' + uid] || {});
if (!Array.isArray(userSocketIds) || !userSocketIds.length) {
return [];
}
uid = parseInt(uid, 10);
var sockets = [];
userSocketIds.forEach(function(sid) {
if (io.sockets.connected[sid] && io.sockets.connected[sid].uid === uid) {
sockets.push(io.sockets.connected[sid]) ;
}
});
return sockets;
};
Sockets.reqFromSocket = function(socket) {
var headers = socket.request.headers,
host = headers.host,

Loading…
Cancel
Save