From 40e09fe2949d2e3136c74a96fb722aa829caf3f3 Mon Sep 17 00:00:00 2001 From: amfl Date: Tue, 14 Jan 2020 14:29:23 +1300 Subject: [PATCH 1/2] bugfix: Correct reference to websocket room name When inside the onmessage function, `this` no longer refers to the websocket node. It needs to be accessed with `that`, which is where we stored it previously. --- src/nodes/network.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nodes/network.js b/src/nodes/network.js index 07bd72c12..12d2c52ab 100644 --- a/src/nodes/network.js +++ b/src/nodes/network.js @@ -86,7 +86,7 @@ this._ws.onmessage = function(e) { that.boxcolor = "#AFA"; var data = JSON.parse(e.data); - if (data.room && data.room != this.properties.room) { + if (data.room && data.room != that.properties.room) { return; } if (e.data.type == 1) { From d134ab73f0d1b6cbb89c77f6e01745855a99022b Mon Sep 17 00:00:00 2001 From: amfl Date: Tue, 14 Jan 2020 14:02:32 +1300 Subject: [PATCH 2/2] bugfix: Websocket checks parsed payload data We parse the JSON payload, but then it wasn't being referred to when we were checking the data type, which could lead to looking at the `type` attribute of a string. --- src/nodes/network.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nodes/network.js b/src/nodes/network.js index 12d2c52ab..0deef5c79 100644 --- a/src/nodes/network.js +++ b/src/nodes/network.js @@ -89,7 +89,7 @@ if (data.room && data.room != that.properties.room) { return; } - if (e.data.type == 1) { + if (data.type == 1) { if ( data.data.object_class && LiteGraph[data.data.object_class] @@ -105,7 +105,7 @@ that.triggerSlot(0, data.data); } } else { - that._last_received_data[e.data.channel || 0] = data.data; + that._last_received_data[data.channel || 0] = data.data; } }; this._ws.onerror = function(e) {