From e61883ba84532aa8ef7aa2ce58bd7990ba97b57a Mon Sep 17 00:00:00 2001 From: rockhowse Date: Wed, 13 Mar 2019 20:57:12 -0500 Subject: [PATCH 1/2] updated websocket to use origin for connectivity instead of localhost --- comms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/comms.js b/comms.js index 835da555e..755463649 100644 --- a/comms.js +++ b/comms.js @@ -1,5 +1,5 @@ -var ws = new WebSocket("ws://127.0.0.1:8080/ws"); -//ws://127.0.0.1:8080 +// Technique used from here: https://github.com/openai/neural-mmo/issues/12#issuecomment-472621615 +var ws = new WebSocket(((window.location.protocol === "https:") ? "wss://" : "ws://") + window.location.host + "/ws"); var inbox = [], outbox = []; /* From 824e3ebcfc2722d6d654c2b7fd2c07a286c0e26b Mon Sep 17 00:00:00 2001 From: rockhowse Date: Wed, 13 Mar 2019 21:05:53 -0500 Subject: [PATCH 2/2] updated the link with the websocket URL auto-configuration --- comms.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/comms.js b/comms.js index 755463649..cd4672c5a 100644 --- a/comms.js +++ b/comms.js @@ -1,4 +1,5 @@ -// Technique used from here: https://github.com/openai/neural-mmo/issues/12#issuecomment-472621615 +// Technique used from here: +// https://stackoverflow.com/questions/10406930/how-to-construct-a-websocket-uri-relative-to-the-page-uri var ws = new WebSocket(((window.location.protocol === "https:") ? "wss://" : "ws://") + window.location.host + "/ws"); var inbox = [], outbox = [];