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