Bootstrap.ts: refine the log prefix string
[e-mobility-charging-stations-simulator.git] / src / charging-station / ChargingStation.ts
index de6756228b1f47d6604389fd8f3e839636b8c4d2..dbabf1e5f118501de1e9f55c0266a2630b7d2c63 100644 (file)
@@ -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;