From e1bc38af838c7f452540dda9f58fcbaa57e334f4 Mon Sep 17 00:00:00 2001 From: jlsa Date: Wed, 5 Jul 2017 20:35:37 +0200 Subject: [PATCH] Added some null pointer catchers --- app.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app.js b/app.js index 8c6a303..6336407 100644 --- a/app.js +++ b/app.js @@ -44,6 +44,9 @@ io.sockets.on('connection', (socket) => { socket.on('forfeit', () => { let game = getGame(socket.id); + if (game == null) { + return; + } let player = game.getPlayer(socket.id); let opponent = game.getOpponent(player); game.forfeit(player); @@ -51,8 +54,13 @@ io.sockets.on('connection', (socket) => { }); socket.on('i know the word', (data) => { + // todo add validation if player can really do this! let game = getGame(socket.id); + + if (game == null) { + return; + } let player = game.getPlayer(socket.id); // let user = getUserById(player.userId); let opponent = game.getOpponent(player);