On socket.io connection, all clients join a room pertaining to
their express session id. We use this room to keep track of any
sessions in different browser windows (but the same cookie jar),
so if a login/logout occurs, we can throw a session mismatch
modal.

This room can also be used to emit messages across windows/tabs...
This commit is contained in:
Julian Lam
2016-11-11 16:47:59 -05:00
parent 38f11f8c28
commit ede7a71db7
4 changed files with 30 additions and 1 deletions

View File

@@ -57,6 +57,7 @@ var ratelimit = require('../middleware/ratelimit');
socket.join('online_guests');
}
socket.join('sess_' + socket.request.signedCookies[nconf.get('sessionKey')]);
io.sockets.sockets[socket.id].emit('checkSession', socket.uid);
}