mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-09 13:36:14 +00:00
send & parse JSON in the ws calls; add cb to avoid crash due to unavailable connection
This commit is contained in:
parent
2e5ba76dd5
commit
fa3212590d
@ -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() {
|
||||
|
@ -34,12 +34,12 @@ class Server {
|
||||
|
||||
app.ws('/embark/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…
x
Reference in New Issue
Block a user