Cleanup: rename isWebSocketOpened to isWebSocketConnectionOpened
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 21 Aug 2021 20:06:59 +0000 (22:06 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 21 Aug 2021 20:06:59 +0000 (22:06 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/OCPPRequestService.ts

index 5c83b7f2b9a044d456b8199156e7d09d40c26386..dbabf1e5f118501de1e9f55c0266a2630b7d2c63 100644 (file)
@@ -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);
@@ -945,7 +945,7 @@ export default class ChargingStation {
     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;
index ccc6fc2b4a919f02030440b17a2fa7af4236c51d..5b1f981cf50a332d4fb3ecb75d3824f52408ac48 100644 (file)
@@ -49,7 +49,7 @@ export default abstract class OCPPRequestService {
           break;
       }
       // Check if wsConnection opened and charging station registered
-      if (this.chargingStation.isWebSocketOpen() && (this.chargingStation.isRegistered() || commandName === RequestCommand.BOOT_NOTIFICATION)) {
+      if (this.chargingStation.isWebSocketConnectionOpened() && (this.chargingStation.isRegistered() || commandName === RequestCommand.BOOT_NOTIFICATION)) {
         if (this.chargingStation.getEnableStatistics()) {
           this.chargingStation.performanceStatistics.addRequestStatistic(commandName, messageType);
         }