Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe6a36f3dc |
@@ -1,5 +1,3 @@
|
|||||||
const BASE_URL = process.env.NEXT_PUBLIC_WEBSOCKET_URL || 'ws://localhost:3000/ws';
|
|
||||||
|
|
||||||
export interface WebSocketMessage {
|
export interface WebSocketMessage {
|
||||||
type: 'step' | 'steam_output' | 'error' | 'complete';
|
type: 'step' | 'steam_output' | 'error' | 'complete';
|
||||||
server_id: string;
|
server_id: string;
|
||||||
@@ -57,9 +55,11 @@ export class WebSocketClient {
|
|||||||
private reconnectTimer: NodeJS.Timeout | null = null;
|
private reconnectTimer: NodeJS.Timeout | null = null;
|
||||||
private shouldReconnect = true;
|
private shouldReconnect = true;
|
||||||
private associatedServerId: string | null = null;
|
private associatedServerId: string | null = null;
|
||||||
|
private baseUrl: string;
|
||||||
|
|
||||||
constructor(token: string) {
|
constructor(token: string) {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
|
this.baseUrl = process.env.NEXT_PUBLIC_WEBSOCKET_URL || 'ws://localhost:3000/ws';
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Promise<void> {
|
connect(): Promise<void> {
|
||||||
@@ -72,7 +72,7 @@ export class WebSocketClient {
|
|||||||
|
|
||||||
this.connectionPromise = new Promise((resolve, reject) => {
|
this.connectionPromise = new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
this.ws = new WebSocket(`${BASE_URL}?token=${this.token}`);
|
this.ws = new WebSocket(`${this.baseUrl}?token=${this.token}`);
|
||||||
|
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
console.log('WebSocket connected');
|
console.log('WebSocket connected');
|
||||||
|
|||||||
Reference in New Issue
Block a user