From ba989bd7f86f823e062cfce7437d89495ef527c6 Mon Sep 17 00:00:00 2001
From: Elizabeth Hunt <elizabeth.hunt@simponic.xyz>
Date: Sat, 2 Sep 2023 18:10:09 -0600
Subject: fix protocol in client JumpStom instance

---
 client/src/components/GameCanvas.svelte | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'client/src/components/GameCanvas.svelte')

diff --git a/client/src/components/GameCanvas.svelte b/client/src/components/GameCanvas.svelte
index ea7dd15..a3f3dbc 100644
--- a/client/src/components/GameCanvas.svelte
+++ b/client/src/components/GameCanvas.svelte
@@ -19,8 +19,10 @@
     const game = new Game();
     const jumpStorm = new JumpStorm(game);
 
-    await jumpStorm.init(ctx, "http", "ws", document.location.host + "/api");
-    jumpStorm.play();
+    const { protocol, host } = document.location;
+    const isHttps = protocol.startsWith('https');
+    jumpStorm.init(ctx, isHttps ? 'https' : 'http', isHttps ? 'wss' : 'ws', `${host}/api`)
+        .then(() => jumpStorm.play());
   });
 </script>
 
-- 
cgit v1.3

