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
1 changed files with 4 additions and 3 deletions

View File

@ -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){