send & parse JSON in the ws calls; add cb to avoid crash due to unavailable connection
This commit is contained in:
parent
5de1c6e539
commit
8bf344e4a0
|
@ -8,7 +8,7 @@ Welcome to Embark!
|
|||
|
||||
ws.onmessage = function (evt) {
|
||||
var received_msg = evt.data;
|
||||
console.log(received_msg);
|
||||
console.log(JSON.parse(received_msg));
|
||||
};
|
||||
|
||||
ws.onclose = function() {
|
||||
|
|
|
@ -69,12 +69,12 @@ class Server {
|
|||
|
||||
this.app.ws('/logs', function(ws, req) {
|
||||
self.events.on("log", function(logLevel, logMsg) {
|
||||
ws.send(logMsg.stripColors);
|
||||
ws.send(JSON.stringify({msg: logMsg, msg_clear: logMsg.stripColors, logLevel: logLevel}), () => {});
|
||||
});
|
||||
ws.on('message', function(msg) {
|
||||
console.dir("got message");
|
||||
console.dir(msg);
|
||||
ws.send(msg);
|
||||
ws.send(msg, () => {});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue