upd: lib.ws-client (Manage JSON parsing on message received)
This commit is contained in:
parent
a2746b6275
commit
b66bafb3c3
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue