Add DataTransfer support for incoming request
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / ui-services / AbstractUIService.ts
index 2cfd85fa97081eafa45116a2d5f886c1ef4f97a2..1d270b38c6c1d5264d90a369a8ed8a74d799968f 100644 (file)
@@ -24,7 +24,9 @@ const moduleName = 'AbstractUIService';
 export default abstract class AbstractUIService {
   protected static readonly ProcedureNameToBroadCastChannelProcedureNameMap: Omit<
     Record<ProcedureName, BroadcastChannelProcedureName>,
-    'startSimulator' | 'stopSimulator' | 'listChargingStations'
+    | ProcedureName.START_SIMULATOR
+    | ProcedureName.STOP_SIMULATOR
+    | ProcedureName.LIST_CHARGING_STATIONS
   > = {
     [ProcedureName.START_CHARGING_STATION]: BroadcastChannelProcedureName.START_CHARGING_STATION,
     [ProcedureName.STOP_CHARGING_STATION]: BroadcastChannelProcedureName.STOP_CHARGING_STATION,
@@ -37,9 +39,11 @@ export default abstract class AbstractUIService {
     [ProcedureName.START_TRANSACTION]: BroadcastChannelProcedureName.START_TRANSACTION,
     [ProcedureName.STOP_TRANSACTION]: BroadcastChannelProcedureName.STOP_TRANSACTION,
     [ProcedureName.AUTHORIZE]: BroadcastChannelProcedureName.AUTHORIZE,
+    [ProcedureName.BOOT_NOTIFICATION]: BroadcastChannelProcedureName.BOOT_NOTIFICATION,
     [ProcedureName.STATUS_NOTIFICATION]: BroadcastChannelProcedureName.STATUS_NOTIFICATION,
     [ProcedureName.HEARTBEAT]: BroadcastChannelProcedureName.HEARTBEAT,
     [ProcedureName.METER_VALUES]: BroadcastChannelProcedureName.METER_VALUES,
+    [ProcedureName.DATA_TRANSFER]: BroadcastChannelProcedureName.DATA_TRANSFER,
   };
 
   protected readonly requestHandlers: Map<ProcedureName, ProtocolRequestHandler>;
@@ -127,7 +131,21 @@ export default abstract class AbstractUIService {
     return this.broadcastChannelRequests.get(uuid) ?? 0;
   }
 
-  protected sendBroadcastChannelRequest(
+  protected handleProtocolRequest(
+    uuid: string,
+    procedureName: ProcedureName,
+    payload: RequestPayload
+  ): void {
+    this.sendBroadcastChannelRequest(
+      uuid,
+      AbstractUIService.ProcedureNameToBroadCastChannelProcedureNameMap[
+        procedureName
+      ] as BroadcastChannelProcedureName,
+      payload
+    );
+  }
+
+  private sendBroadcastChannelRequest(
     uuid: string,
     procedureName: BroadcastChannelProcedureName,
     payload: BroadcastChannelRequestPayload
@@ -154,20 +172,6 @@ export default abstract class AbstractUIService {
     this.broadcastChannelRequests.set(uuid, expectedNumberOfResponses);
   }
 
-  protected handleProtocolRequest(
-    uuid: string,
-    procedureName: ProcedureName,
-    payload: RequestPayload
-  ): void {
-    this.sendBroadcastChannelRequest(
-      uuid,
-      AbstractUIService.ProcedureNameToBroadCastChannelProcedureNameMap[
-        procedureName
-      ] as BroadcastChannelProcedureName,
-      payload
-    );
-  }
-
   private handleListChargingStations(): ResponsePayload {
     return {
       status: ResponseStatus.SUCCESS,