From 1567a097c39568a730eb6d370c9362be3a501ca1 Mon Sep 17 00:00:00 2001 From: Michael Clapham Date: Sat, 21 Sep 2024 17:36:10 +0100 Subject: [PATCH] Prevent WSClient from being created twice --- src/App.tsx | 7 ++++--- src/WSClient.ts | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 0f1d2c4..e2ac1db 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,10 +10,11 @@ import { SessionPage } from "./feature/session/SessionPage"; import { NavigateOnStateChange } from "./NavigateOnStateChange"; import { SessionMessage, mapSessionMsg } from "./feature/session/SessionMessage"; +// let wsUrl = "wss://qrsync.org/api/v1/ws"; +let wsUrl = "ws://localhost:4010/api/v1/ws"; +const wsClient = new WSClient(wsUrl); + export const App: React.FC = () => { - // let wsUrl = "wss://qrsync.org/api/v1/ws"; - let wsUrl = "ws://localhost:4010/api/v1/ws"; - const [wsClient] = useState(new WSClient(wsUrl)); const [ourClientId, setOurClientId] = useState(); const [sessionOwnerId, setSessionOwnerId] = useState(); const [sessionId, setSessionId] = useState(); diff --git a/src/WSClient.ts b/src/WSClient.ts index 84118e0..70d3bc2 100644 --- a/src/WSClient.ts +++ b/src/WSClient.ts @@ -10,6 +10,7 @@ export class WSClient { clientName: string = ""; constructor(private url: string) { + console.log("WSClient being created"); this.ws = this.connect(url); }