X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2FChargingStationWorkerBroadcastChannel.ts;h=e36650bb3cb2ab1c4d2281e8bbd0dc2ac0cb7f63;hb=d273692c3ddee7eb01353e032304762a993c33e2;hp=08126286b15d5cbe6ed378e9c41045232347fb76;hpb=9d73266c8bb85d7e2bc1fab9954a76910fd689eb;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStationWorkerBroadcastChannel.ts b/src/charging-station/ChargingStationWorkerBroadcastChannel.ts index 08126286..e36650bb 100644 --- a/src/charging-station/ChargingStationWorkerBroadcastChannel.ts +++ b/src/charging-station/ChargingStationWorkerBroadcastChannel.ts @@ -34,21 +34,22 @@ type CommandResponse = | StatusNotificationResponse | HeartbeatResponse; +type CommandHandler = ( + requestPayload?: BroadcastChannelRequestPayload +) => Promise | void; + export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChannel { - private readonly commandHandlers: Map< - BroadcastChannelProcedureName, - (requestPayload?: BroadcastChannelRequestPayload) => Promise | void - >; + private readonly commandHandlers: Map; private readonly chargingStation: ChargingStation; constructor(chargingStation: ChargingStation) { super(); - this.commandHandlers = new Map([ + this.commandHandlers = new Map([ [BroadcastChannelProcedureName.START_CHARGING_STATION, () => this.chargingStation.start()], [ BroadcastChannelProcedureName.STOP_CHARGING_STATION, - async () => await this.chargingStation.stop(), + async () => this.chargingStation.stop(), ], [ BroadcastChannelProcedureName.OPEN_CONNECTION,