Encode ws messages as JSON

This commit is contained in:
eikek
2021-11-11 21:55:31 +01:00
parent d0f3d54060
commit cf933b60a7
10 changed files with 99 additions and 46 deletions

View File

@ -157,8 +157,12 @@ function initWS() {
console.log("Initialize websocket at " + url);
dsWebSocket = new WebSocket(url);
dsWebSocket.addEventListener("message", function(event) {
if (event.data != "keep-alive" && event.data) {
elmApp.ports.receiveWsMessage.send(event.data);
if (event.data) {
var dataJSON = JSON.parse(event.data);
if (dataJSON.tag !== "keep-alive") {
elmApp.ports.receiveWsMessage.send(dataJSON);
}
}
});
}