From d09085e9e6ec32bb1873b8f4cc1b326f7996d0f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 12 Sep 2021 13:40:28 +0200 Subject: [PATCH] Type a ws callback MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index e63e067d..72c781fc 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -631,16 +631,16 @@ export default class ChargingStation { this.hasSocketRestarted = false; } - private async onClose(closeEvent: any): Promise { - switch (closeEvent) { + private async onClose(code: number): Promise { + switch (code) { case WebSocketCloseEventStatusCode.CLOSE_NORMAL: // Normal close case WebSocketCloseEventStatusCode.CLOSE_NO_STATUS: - logger.info(`${this.logPrefix()} Socket normally closed with status '${Utils.getWebSocketCloseEventStatusString(closeEvent)}'`); + logger.info(`${this.logPrefix()} Socket normally closed with status '${Utils.getWebSocketCloseEventStatusString(code)}'`); this.autoReconnectRetryCount = 0; break; default: // Abnormal close - logger.error(`${this.logPrefix()} Socket abnormally closed with status '${Utils.getWebSocketCloseEventStatusString(closeEvent)}'`); - await this.reconnect(closeEvent); + logger.error(`${this.logPrefix()} Socket abnormally closed with status '${Utils.getWebSocketCloseEventStatusString(code)}'`); + await this.reconnect(code); break; } } @@ -1035,7 +1035,7 @@ export default class ChargingStation { return !Utils.isUndefined(this.stationInfo.reconnectExponentialDelay) ? this.stationInfo.reconnectExponentialDelay : false; } - private async reconnect(error: Error): Promise { + private async reconnect(code: number): Promise { // Stop WebSocket ping this.stopWebSocketPing(); // Stop heartbeat -- 2.34.1