fix: ensure the message buffer is flushed once accepted state is reached
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 20 Nov 2023 22:15:40 +0000 (23:15 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 20 Nov 2023 22:15:40 +0000 (23:15 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 0ab700a5d0848836d1aaf26e63bc6e8ebb6b1d39..e354b4b5164979c794e43a26b740ed9e2295db9b 100644 (file)
@@ -183,7 +183,6 @@ export class ChargingStation extends EventEmitter {
   private ocppIncomingRequestService!: OCPPIncomingRequestService;
   private readonly messageBuffer: Set<string>;
   private configuredSupervisionUrl!: URL;
-  private wsConnectionRestarted: boolean;
   private autoReconnectRetryCount: number;
   private templateFileWatcher!: FSWatcher | undefined;
   private templateFileHash!: string;
@@ -198,7 +197,6 @@ export class ChargingStation extends EventEmitter {
     this.starting = false;
     this.stopping = false;
     this.wsConnection = null;
-    this.wsConnectionRestarted = false;
     this.autoReconnectRetryCount = 0;
     this.index = index;
     this.templateFile = templateFile;
@@ -1789,7 +1787,6 @@ export class ChargingStation extends EventEmitter {
             .stationInfo?.registrationMaxRetries})`,
         );
       }
-      this.wsConnectionRestarted = false;
       this.autoReconnectRetryCount = 0;
       this.emit(ChargingStationEvents.updated);
     } else {
@@ -2157,7 +2154,7 @@ export class ChargingStation extends EventEmitter {
     if (this.getAutomaticTransactionGeneratorConfiguration().enable === true) {
       this.startAutomaticTransactionGenerator();
     }
-    this.wsConnectionRestarted === true && this.flushMessageBuffer();
+    this.flushMessageBuffer();
   }
 
   private async stopMessageSequence(
@@ -2345,7 +2342,6 @@ export class ChargingStation extends EventEmitter {
         },
         { closeOpened: true },
       );
-      this.wsConnectionRestarted = true;
     } else if (this.stationInfo?.autoReconnectMaxRetries !== -1) {
       logger.error(
         `${this.logPrefix()} WebSocket connection retries failure: maximum retries reached (${