Do not crash on malformed json message on websocket.

This commit is contained in:
Mark Hindess 2014-07-24 14:46:04 +01:00
parent 6bc4b235bb
commit 8506fd0c4b
1 changed files with 7 additions and 1 deletions

View File

@ -50,7 +50,13 @@ function start() {
}
});
ws.on('message', function(data,flags) {
var msg = JSON.parse(data);
var msg = null;
try {
msg = JSON.parse(data);
} catch(err) {
util.log("[red:comms] received malformed message : "+err.toString());
return;
}
if (msg.subscribe) {
handleRemoteSubscription(ws,msg.subscribe);
}