fix(back): prevent crash

This commit is contained in:
Florent Chehab 2020-05-10 23:10:54 +02:00
parent 52f52b62e4
commit 9fda0a2c4b
No known key found for this signature in database
GPG Key ID: 9A0CE018889EA246

View File

@ -194,6 +194,7 @@ function startBackendServer(port) {
io.on("connection", function (socket) {
var whiteboardId = null;
socket.on("disconnect", function () {
if (infoByWhiteboard.has(whiteboardId)) {
const whiteboardServerSideInfo = infoByWhiteboard.get(whiteboardId);
if (socket && socket.id) {
@ -201,11 +202,13 @@ function startBackendServer(port) {
}
whiteboardServerSideInfo.decrementNbConnectedUsers();
if (whiteboardServerSideInfo.hasConnectedUser()) {
socket.compress(false).broadcast.emit("refreshUserBadges", null); //Removes old user Badges
} else {
infoByWhiteboard.delete(whiteboardId);
}
}
});
socket.on("drawToWhiteboard", function (content) {