From: Jérôme Benoit Date: Sun, 12 Sep 2021 11:40:28 +0000 (+0200) Subject: Type a ws callback X-Git-Tag: v1.0.58~11 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d09085e9e6ec32bb1873b8f4cc1b326f7996d0f3;p=e-mobility-charging-stations-simulator.git Type a ws callback Signed-off-by: Jérôme Benoit --- 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