Prevent crashing when getting messages of the old protocolversion

This commit is contained in:
Peter 'Pita' Martischka 2011-06-27 23:06:05 +02:00
parent 84b0521c85
commit 75dd468f50
1 changed files with 7 additions and 1 deletions

View File

@ -58,6 +58,12 @@ exports.setSocketIO = function(_socket)
client.on('message', function(message)
{
if(!message.protocolVersion|| message.protocolVersion != 2)
{
console.error("Protocolversion header is not correct:" + JSON.stringify(message));
return;
}
//route this message to the correct component, if possible
if(message.component && components[message.component])
{
@ -71,7 +77,7 @@ exports.setSocketIO = function(_socket)
}
else
{
throw "Can't route the message:" + JSON.stringify(message);
console.error("Can't route the message:" + JSON.stringify(message));
}
});