Skip to content

Commit

Permalink
Prevent WSClient from being created twice
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelclapham committed Sep 21, 2024
1 parent 8bbe2fa commit 1567a09
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<WSClient>(new WSClient(wsUrl));
const [ourClientId, setOurClientId] = useState<string>();
const [sessionOwnerId, setSessionOwnerId] = useState<string>();
const [sessionId, setSessionId] = useState<string>();
Expand Down
1 change: 1 addition & 0 deletions src/WSClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class WSClient {
clientName: string = "";

constructor(private url: string) {
console.log("WSClient being created");
this.ws = this.connect(url);
}

Expand Down

0 comments on commit 1567a09

Please sign in to comment.