Skip to content

Commit

Permalink
print reconnecting log once
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardssh committed Dec 18, 2022
1 parent e3072a6 commit 0f99354
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,16 @@ export class Client {
}

private initializeSocketIO(): void {
let reconnectingLog = false

this.socketIO.on('connect', () => {
if (this.reconnectTimeout) {
clearTimeout(this.reconnectTimeout);
this.reconnectTimeout = null;
}

console.log(`${yellow('[SOCKET]')} Connection established.`)
reconnectingLog = true
})

this.socketIO.on('connect_error', () => {
Expand All @@ -108,7 +111,10 @@ export class Client {

this.rejectCalls()

console.log(`${red('[SOCKET]')} Connection error. Reconnecting...`)
if (!reconnectingLog) {
console.log(`${red('[SOCKET]')} Connection error. Reconnecting...`)
reconnectingLog = true
}

this.reconnectTimeout = setTimeout(() => {
this.open()
Expand Down

0 comments on commit 0f99354

Please sign in to comment.