We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 13b0b2d commit 38bf006Copy full SHA for 38bf006
src/services/websocket.ts
@@ -10,6 +10,9 @@ export enum ConnectionStatus {
10
ERROR = "error",
11
}
12
13
+const protocol = location.protocol === "https:" ? "wss:" : "ws:";
14
+const defaultUrl = protocol + "//" + location.host + "/api/ws";
15
+
16
// WebSocket client class
17
class WebSocketClient {
18
private socket: WebSocket | null = null;
@@ -29,7 +32,7 @@ class WebSocketClient {
29
32
);
30
33
31
34
// Connect to WebSocket server
- public connect(url: string = "ws://" + location.host + "/api/ws"): void {
35
+ public connect(url: string = defaultUrl): void {
36
if (this.socket && this.isConnected.value) {
37
console.log("WebSocket already connected");
38
return;
0 commit comments