fix(back): prevent crash
This commit is contained in:
parent
52f52b62e4
commit
9fda0a2c4b
@ -194,6 +194,7 @@ function startBackendServer(port) {
|
|||||||
io.on("connection", function (socket) {
|
io.on("connection", function (socket) {
|
||||||
var whiteboardId = null;
|
var whiteboardId = null;
|
||||||
socket.on("disconnect", function () {
|
socket.on("disconnect", function () {
|
||||||
|
if (infoByWhiteboard.has(whiteboardId)) {
|
||||||
const whiteboardServerSideInfo = infoByWhiteboard.get(whiteboardId);
|
const whiteboardServerSideInfo = infoByWhiteboard.get(whiteboardId);
|
||||||
|
|
||||||
if (socket && socket.id) {
|
if (socket && socket.id) {
|
||||||
@ -201,11 +202,13 @@ function startBackendServer(port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
whiteboardServerSideInfo.decrementNbConnectedUsers();
|
whiteboardServerSideInfo.decrementNbConnectedUsers();
|
||||||
|
|
||||||
if (whiteboardServerSideInfo.hasConnectedUser()) {
|
if (whiteboardServerSideInfo.hasConnectedUser()) {
|
||||||
socket.compress(false).broadcast.emit("refreshUserBadges", null); //Removes old user Badges
|
socket.compress(false).broadcast.emit("refreshUserBadges", null); //Removes old user Badges
|
||||||
} else {
|
} else {
|
||||||
infoByWhiteboard.delete(whiteboardId);
|
infoByWhiteboard.delete(whiteboardId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("drawToWhiteboard", function (content) {
|
socket.on("drawToWhiteboard", function (content) {
|
||||||
|
Loading…
Reference in New Issue
Block a user