X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=dbabf1e5f118501de1e9f55c0266a2630b7d2c63;hb=689dca78d8b50e58be603005695da60ae3070544;hp=de6756228b1f47d6604389fd8f3e839636b8c4d2;hpb=15042c5fdee2d617c1d533699334cbf044f1a97e;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index de675622..dbabf1e5 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -16,7 +16,7 @@ import Configuration from '../utils/Configuration'; import Constants from '../utils/Constants'; import FileUtils from '../utils/FileUtils'; import { MessageType } from '../types/ocpp/MessageType'; -import OCPP16IncomingRequestService from './ocpp/1.6/OCCP16IncomingRequestService'; +import OCPP16IncomingRequestService from './ocpp/1.6/OCPP16IncomingRequestService'; import OCPP16RequestService from './ocpp/1.6/OCPP16RequestService'; import OCPP16ResponseService from './ocpp/1.6/OCPP16ResponseService'; import OCPPError from './OCPPError'; @@ -103,7 +103,7 @@ export default class ChargingStation { } } - public isWebSocketOpen(): boolean { + public isWebSocketConnectionOpened(): boolean { return this.wsConnection?.readyState === WebSocket.OPEN; } @@ -330,7 +330,7 @@ export default class ChargingStation { this.getConnector(Utils.convertToInt(connector)).status = ChargePointStatus.UNAVAILABLE; } } - if (this.isWebSocketOpen()) { + if (this.isWebSocketConnectionOpened()) { this.wsConnection.close(); } if (this.getEnableStatistics()) { @@ -613,7 +613,7 @@ export default class ChargingStation { if (this.isRegistered()) { await this.startMessageSequence(); this.hasStopped && (this.hasStopped = false); - if (this.hasSocketRestarted && this.isWebSocketOpen()) { + if (this.hasSocketRestarted && this.isWebSocketConnectionOpened()) { this.flushMessageQueue(); } } else { @@ -887,7 +887,7 @@ export default class ChargingStation { : 0; if (webSocketPingInterval > 0 && !this.webSocketPingSetInterval) { this.webSocketPingSetInterval = setInterval(() => { - if (this.isWebSocketOpen()) { + if (this.isWebSocketConnectionOpened()) { this.wsConnection.ping((): void => { }); } }, webSocketPingInterval * 1000); @@ -940,12 +940,12 @@ export default class ChargingStation { } private openWSConnection(options?: ClientOptions & ClientRequestArgs, forceCloseOpened = false): void { - options ?? {}; - options?.handshakeTimeout ?? this.getConnectionTimeout() * 1000; + options = options ?? {}; + options.handshakeTimeout = options?.handshakeTimeout ?? this.getConnectionTimeout() * 1000; if (!Utils.isNullOrUndefined(this.stationInfo.supervisionUser) && !Utils.isNullOrUndefined(this.stationInfo.supervisionPassword)) { options.auth = `${this.stationInfo.supervisionUser}:${this.stationInfo.supervisionPassword}`; } - if (this.isWebSocketOpen() && forceCloseOpened) { + if (this.isWebSocketConnectionOpened() && forceCloseOpened) { this.wsConnection.close(); } let protocol;