From 9ab207faa0f4b5919f477f8c2c33f35a5bf33694 Mon Sep 17 00:00:00 2001 From: cracker0dks Date: Sun, 2 Jun 2019 17:38:14 +0200 Subject: [PATCH] catch server error when id or obj is not set --- server.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index ae3e37c..33f34f3 100644 --- a/server.js +++ b/server.js @@ -122,7 +122,9 @@ io.on('connection', function (socket) { var whiteboardId = null; socket.on('disconnect', function () { - delete smallestScreenResolutions[whiteboardId][socket.id]; + if(smallestScreenResolutions && smallestScreenResolutions[whiteboardId] && socket && socket.id) { + delete smallestScreenResolutions[whiteboardId][socket.id]; + } socket.broadcast.emit('refreshUserBadges', null); //Removes old user Badges sendSmallestScreenResolution(); });