diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-09-02 18:10:09 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-09-02 18:10:09 -0600 |
commit | ba989bd7f86f823e062cfce7437d89495ef527c6 (patch) | |
tree | b60c2b16c9d38f66c70122914568a17438474e70 | |
parent | c9070bb0566b30fc64481193d3571284296ee14b (diff) | |
download | jumpstorm-ba989bd7f86f823e062cfce7437d89495ef527c6.tar.gz jumpstorm-ba989bd7f86f823e062cfce7437d89495ef527c6.zip |
fix protocol in client JumpStom instance
-rw-r--r-- | client/src/components/GameCanvas.svelte | 6 |
1 files changed, 4 insertions, 2 deletions
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> |