Fixes crash if a socket could not be matched to a quiz

parent 8673d2e8
......@@ -78,8 +78,13 @@ export class WebSocketRouter {
WebSocketRouter.sendQuizStatusUpdate(ws, MessageProtocol.Connected, { activeQuizzes: QuizDAO.getJoinableQuizzes().map(val => val.name) });
};
const quizSessionUpdateHandler = () => {
WebSocketRouter.sendQuizStatusUpdate(ws, MessageProtocol.UpdatedSettings,
{ sessionConfig: QuizDAO.getQuizBySocket(ws).sessionConfig.serialize() });
const quiz = QuizDAO.getQuizBySocket(ws);
if (!quiz) {
console.error('Cannot publish session update to the socket. Could not find an attached quiz');
return;
}
WebSocketRouter.sendQuizStatusUpdate(ws, MessageProtocol.UpdatedSettings, { sessionConfig: quiz.sessionConfig.serialize() });
};
ws['isAlive'] = true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment