Check for type and data not being undefined

This commit is contained in:
Melvin Valster 2017-01-24 11:22:53 +01:00
parent cfcf815275
commit 4f9f206b42

View file

@ -175,12 +175,13 @@ function gotData(socket,data,UDPSocket){
while(data.length>0){ while(data.length>0){
let message=new Message; let message=new Message;
message.load(data.shift()); message.load(data.shift());
// In case either `type` or `data` is missing we won't process this message. // 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; continue;
} }
this.log('received event of : ',message.type,message.data); this.log('received event of : ',message.type,message.data);
if(message.data.id){ if(message.data.id){