Null checks

This commit is contained in:
Marcus Noble 2020-12-13 16:27:47 +00:00
parent 02b7708976
commit a18644d40e
2 changed files with 12 additions and 8 deletions

View File

@ -1,4 +1,4 @@
FROM node:12 FROM node:14
WORKDIR /app WORKDIR /app

18
room.js
View File

@ -108,9 +108,11 @@ function reset(roomId) {
room.canBuzz = true; room.canBuzz = true;
room.participants.forEach(p => { room.participants.forEach(p => {
p.ws.send(JSON.stringify({ if (p.ws) {
type: "reset" p.ws.send(JSON.stringify({
})); type: "reset"
}));
}
}); });
} }
@ -137,10 +139,12 @@ function updateScore(roomId, participantId, points) {
participant.score += points; participant.score += points;
participant.ws.send(JSON.stringify({ if (participant.ws) {
type: "score", participant.ws.send(JSON.stringify({
score: participant.score, type: "score",
})); score: participant.score,
}));
}
} }
room.audience.forEach(ws => { room.audience.forEach(ws => {