From 4f9f206b427e0ed56d9f4bdd65513252aa945f6c Mon Sep 17 00:00:00 2001 From: Melvin Valster Date: Tue, 24 Jan 2017 11:22:53 +0100 Subject: [PATCH] Check for type and data not being undefined --- dao/socketServer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dao/socketServer.js b/dao/socketServer.js index 296406d..4e01e52 100644 --- a/dao/socketServer.js +++ b/dao/socketServer.js @@ -175,12 +175,13 @@ function gotData(socket,data,UDPSocket){ while(data.length>0){ let message=new Message; message.load(data.shift()); - + // In case either `type` or `data` is missing we won't process this message. - if (!message.type || !message.data) { + if (message.type === undefined || message.data === undefined) { + this.log('Message is missing either `type` or `data` property, skipping message.'); continue; } - + this.log('received event of : ',message.type,message.data); if(message.data.id){