Skip to content

Commit

Permalink
FIx: frontend works after backend restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan-Computas committed Oct 3, 2024
1 parent 8b5a0b8 commit 4bbeb59
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/app/game/services/web-socket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { GameStateService } from '../services/game-state-service';
export class WebSocketService {
socket: Socket | undefined;
private retryAttempts = 0;
private maxRetries = 5;
private maxRetries = 2;
private retryDelay = 3000;

playerDisconnectedData: PlayerDisconnectedData | undefined;
Expand Down Expand Up @@ -78,19 +78,14 @@ export class WebSocketService {
}

disconnect() {
if (this.socket && ! this.socket.disconnected) {
console.warn('socket disconnecting and removing listener');
if (this.socket) {
this.socket.removeAllListeners();
this.socket.disconnect();
this.socket = undefined;
this.isConnected = false;
this.isRetrying = false;
console.log("Websocket closed properly")
this.retryAttempts = 0;
} else if (this.socket) {
this.socket.removeAllListeners();
this.socket.disconnect();
console.log("Websocket closed properly without ever being connected")
console.log("Websocket closed properly");
}
}

Expand Down

0 comments on commit 4bbeb59

Please sign in to comment.