aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/GolfWatchApp.tsx
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-29 20:04:03 +0900
committernsfisis <nsfisis@gmail.com>2024-07-29 20:04:09 +0900
commit648613e24c8afe5fd3c599def61b33ccf7bcb96c (patch)
treef368aa1ef1d734d3096c9129e17d6af11d1041a6 /frontend/app/components/GolfWatchApp.tsx
parentd73fd8bf5bf589a4a391c867e980761fadb647ce (diff)
downloadphperkaigi-2025-albatross-648613e24c8afe5fd3c599def61b33ccf7bcb96c.tar.gz
phperkaigi-2025-albatross-648613e24c8afe5fd3c599def61b33ccf7bcb96c.tar.zst
phperkaigi-2025-albatross-648613e24c8afe5fd3c599def61b33ccf7bcb96c.zip
feat: authenticate WebSocket connection by short-lived access token
Diffstat (limited to 'frontend/app/components/GolfWatchApp.tsx')
-rw-r--r--frontend/app/components/GolfWatchApp.tsx14
1 files changed, 10 insertions, 4 deletions
diff --git a/frontend/app/components/GolfWatchApp.tsx b/frontend/app/components/GolfWatchApp.tsx
index bcd1f0f..00ad005 100644
--- a/frontend/app/components/GolfWatchApp.tsx
+++ b/frontend/app/components/GolfWatchApp.tsx
@@ -14,12 +14,18 @@ type Problem = components["schemas"]["Problem"];
type GameState = "connecting" | "waiting" | "starting" | "gaming" | "finished";
-export default function GolfWatchApp({ game }: { game: Game }) {
- // const socketUrl = `wss://t.nil.ninja/iosdc/2024/sock/golf/${game.game_id}/play`;
+export default function GolfWatchApp({
+ game,
+ sockToken,
+}: {
+ game: Game;
+ sockToken: string;
+}) {
+ // const socketUrl = `wss://t.nil.ninja/iosdc/2024/sock/golf/${game.game_id}/watch?token=${sockToken}`;
const socketUrl =
process.env.NODE_ENV === "development"
- ? `ws://localhost:8002/sock/golf/${game.game_id}/play`
- : `ws://api-server/sock/golf/${game.game_id}/play`;
+ ? `ws://localhost:8002/sock/golf/${game.game_id}/watch?token=${sockToken}`
+ : `ws://api-server/sock/golf/${game.game_id}/watch?token=${sockToken}`;
const { lastJsonMessage, readyState } = useWebSocket<WebSocketMessage>(
socketUrl,