From 75dd468f5022b5555790efd17c2f6a4b4d6ac1c2 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Mon, 27 Jun 2011 23:06:05 +0200 Subject: [PATCH] Prevent crashing when getting messages of the old protocolversion --- node/SocketIORouter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/node/SocketIORouter.js b/node/SocketIORouter.js index 155ee881..1b8fffed 100644 --- a/node/SocketIORouter.js +++ b/node/SocketIORouter.js @@ -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)); } });