diff --git a/receivers/common/web/ConnectionMonitor.ts b/receivers/common/web/ConnectionMonitor.ts index 52f9a51..3732b9e 100644 --- a/receivers/common/web/ConnectionMonitor.ts +++ b/receivers/common/web/ConnectionMonitor.ts @@ -41,12 +41,13 @@ export class ConnectionMonitor { setInterval(() => { if (ConnectionMonitor.backendConnections.size > 0) { - for (const sessionId in ConnectionMonitor.backendConnections) { + for (const sessionId of ConnectionMonitor.backendConnections.keys()) { if (ConnectionMonitor.heartbeatRetries.get(sessionId) > 3) { ConnectionMonitor.logger.warn(`Could not ping device with connection id ${sessionId}. Disconnecting...`); ConnectionMonitor.backendConnections.get(sessionId).disconnect(sessionId); } + ConnectionMonitor.logger.debug(`Pinging session ${sessionId} with ${ConnectionMonitor.heartbeatRetries.get(sessionId)} retries left`); ConnectionMonitor.backendConnections.get(sessionId).send(Opcode.Ping, null); ConnectionMonitor.heartbeatRetries.set(sessionId, ConnectionMonitor.heartbeatRetries.get(sessionId) === undefined ? 1 : ConnectionMonitor.heartbeatRetries.get(sessionId) + 1); } @@ -58,7 +59,8 @@ export class ConnectionMonitor { } public static onPingPong(value: any) { - ConnectionMonitor.heartbeatRetries[value.sessionId] = 0; + ConnectionMonitor.logger.debug(`Received response from ${value.sessionId}`); + ConnectionMonitor.heartbeatRetries.set(value.sessionId, 0); } public static onConnect(listener: any, value: any) { diff --git a/receivers/common/web/FCastSession.ts b/receivers/common/web/FCastSession.ts index 87325da..98ddf44 100644 --- a/receivers/common/web/FCastSession.ts +++ b/receivers/common/web/FCastSession.ts @@ -35,7 +35,7 @@ export class FCastSession { send(opcode: number, message = null) { const json = message ? JSON.stringify(message) : null; - logger.info(`send (opcode: ${opcode}, body: ${json})`); + logger.info(`send: (session: ${this.sessionId}, opcode: ${opcode}, body: ${json})`); let data: Uint8Array; if (json) { @@ -164,7 +164,7 @@ export class FCastSession { } private handlePacket(opcode: number, body: string | undefined) { - logger.info(`handlePacket (opcode: ${opcode}, body: ${body})`); + logger.info(`handlePacket: (session: ${this.sessionId}, opcode: ${opcode}, body: ${body})`); try { switch (opcode) {