feat: add `deleteChargingStations` SRPC command to UI Services
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / ui-services / AbstractUIService.ts
index 4055837fe18d89700e4f22f31bc01f0a1391fa1a..f8a147895414112bd9f774179092d8d7a89a0a73 100644 (file)
@@ -29,6 +29,10 @@ export abstract class AbstractUIService {
   >([
     [ProcedureName.START_CHARGING_STATION, BroadcastChannelProcedureName.START_CHARGING_STATION],
     [ProcedureName.STOP_CHARGING_STATION, BroadcastChannelProcedureName.STOP_CHARGING_STATION],
+    [
+      ProcedureName.DELETE_CHARGING_STATIONS,
+      BroadcastChannelProcedureName.DELETE_CHARGING_STATIONS
+    ],
     [ProcedureName.CLOSE_CONNECTION, BroadcastChannelProcedureName.CLOSE_CONNECTION],
     [ProcedureName.OPEN_CONNECTION, BroadcastChannelProcedureName.OPEN_CONNECTION],
     [
@@ -79,6 +83,11 @@ export abstract class AbstractUIService {
     this.broadcastChannelRequests = new Map<string, number>()
   }
 
+  public stop (): void {
+    this.broadcastChannelRequests.clear()
+    this.uiServiceWorkerBroadcastChannel.close()
+  }
+
   public async requestHandler (request: ProtocolRequest): Promise<ProtocolResponse | undefined> {
     let messageId: string | undefined
     let command: ProcedureName | undefined