UI protocol: Allow to send some relevant commands to several charging… (#152)
[e-mobility-charging-stations-simulator.git] / src / types / WorkerBroadcastChannel.ts
1 import { RequestPayload, ResponsePayload } from './UIProtocol';
2
3 export type BroadcastChannelRequest = [
4 string,
5 BroadcastChannelProcedureName,
6 BroadcastChannelRequestPayload
7 ];
8 export type BroadcastChannelResponse = [string, BroadcastChannelResponsePayload];
9
10 export enum BroadcastChannelProcedureName {
11 START_CHARGING_STATION = 'startChargingStation',
12 STOP_CHARGING_STATION = 'stopChargingStation',
13 START_TRANSACTION = 'startTransaction',
14 STOP_TRANSACTION = 'stopTransaction',
15 OPEN_CONNECTION = 'openConnection',
16 CLOSE_CONNECTION = 'closeConnection',
17 }
18
19 interface BaseBroadcastChannelRequestPayload extends Omit<RequestPayload, 'hashId' | 'hashIds'> {
20 connectorId?: number;
21 transactionId?: number;
22 idTag?: string;
23 }
24
25 interface HashIdBroadcastChannelRequestPayload extends BaseBroadcastChannelRequestPayload {
26 hashId: string;
27 }
28
29 interface HashIdsBroadcastChannelRequestPayload extends BaseBroadcastChannelRequestPayload {
30 hashIds: string[];
31 }
32
33 export type BroadcastChannelRequestPayload =
34 | HashIdBroadcastChannelRequestPayload
35 | HashIdsBroadcastChannelRequestPayload;
36
37 export type BroadcastChannelResponsePayload = ResponsePayload;
38
39 export type MessageEvent = { data: BroadcastChannelRequest | BroadcastChannelResponse };