diff --git a/view/lib/ws-client-es6.js b/view/lib/ws-client-es6.js index 5d95fe0..bf8a357 100644 --- a/view/lib/ws-client-es6.js +++ b/view/lib/ws-client-es6.js @@ -132,8 +132,19 @@ class WSClient{ return; } - /* (3) If all right -> success */ - this.on_receive(msg_event.data, null); + /* (3) Try to JSON parse */ + var parsedMsg = null; + try{ + + parsedMsg = JSON.parse(msg_event.data); + + }catch(e){ + this.on_receive(null, 'JSON error'); + return; + } + + /* (4) If all right -> success */ + this.on_receive(parsedMsg, null); }