From fca8483ac67787b2f85699085d29930a4c4682b8 Mon Sep 17 00:00:00 2001 From: Thilo Behnke Date: Thu, 23 Jun 2022 00:03:25 +0200 Subject: [PATCH] join session --- client/svelte-client/src/api/session.ts | 13 ++++--------- .../src/components/ModeSelect.svelte | 15 ++++++++++++++- .../src/components/SessionWrapper.svelte | 2 +- client/svelte-client/src/store/session.ts | 6 ++---- server/src/request_handler.rs | 5 ++--- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/client/svelte-client/src/api/session.ts b/client/svelte-client/src/api/session.ts index 0ac7eee..226cb82 100644 --- a/client/svelte-client/src/api/session.ts +++ b/client/svelte-client/src/api/session.ts @@ -24,19 +24,14 @@ async function createNetworkSession(): Promise { }); } -const joinSessionPath = "/pong/api/join_session" - -function createJoinLink(sessionId: string, relative = false): string { - let link = `${joinSessionPath}?session_id=${sessionId}`; - if (!relative) { - link = window.location.origin + link; - } - return link; +function createJoinLink(sessionId: string): string { + return `${window.location.origin}${window.location.pathname}?session_id=${sessionId}`; } async function joinNetworkSession(sessionId): Promise { - return fetch(createJoinLink(sessionId, true), { + return fetch("/pong/api/join_session", { method: 'POST', + body: JSON.stringify({session_id: sessionId}), headers: [['Content-Type', 'application/json']] }) .then(sessionResponseHandler) diff --git a/client/svelte-client/src/components/ModeSelect.svelte b/client/svelte-client/src/components/ModeSelect.svelte index cc545f4..b733709 100644 --- a/client/svelte-client/src/components/ModeSelect.svelte +++ b/client/svelte-client/src/components/ModeSelect.svelte @@ -1,6 +1,7 @@