mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-04 06:40:44 +01:00
Merge pull request #704 from akhoury/master
guarding against Errors on Socket Disconnect
This commit is contained in:
@@ -106,12 +106,12 @@ websockets.init = function(io) {
|
||||
|
||||
socket.on('disconnect', function() {
|
||||
|
||||
var index = userSockets[uid].indexOf(socket);
|
||||
var index = (userSockets[uid] || []).indexOf(socket);
|
||||
if (index !== -1) {
|
||||
userSockets[uid].splice(index, 1);
|
||||
}
|
||||
|
||||
if (userSockets[uid].length === 0) {
|
||||
if (userSockets[uid] && userSockets[uid].length === 0) {
|
||||
delete users[sessionID];
|
||||
delete userSockets[uid];
|
||||
if (uid) {
|
||||
|
||||
Reference in New Issue
Block a user