Add WebSocket connection close and open support to the UI protocol
[e-mobility-charging-stations-simulator.git] / src / types / WorkerBroadcastChannel.ts
1 import { JsonObject } from './JsonType';
2 import { RequestPayload, ResponsePayload } from './UIProtocol';
3
4 export type BroadcastChannelRequest = [
5 string,
6 BroadcastChannelProcedureName,
7 BroadcastChannelRequestPayload
8 ];
9 export type BroadcastChannelResponse = [string, BroadcastChannelResponsePayload];
10
11 export enum BroadcastChannelProcedureName {
12 START_CHARGING_STATION = 'startChargingStation',
13 STOP_CHARGING_STATION = 'stopChargingStation',
14 START_TRANSACTION = 'startTransaction',
15 STOP_TRANSACTION = 'stopTransaction',
16 OPEN_CONNECTION = 'openConnection',
17 CLOSE_CONNECTION = 'closeConnection',
18 }
19
20 export interface BroadcastChannelRequestPayload extends Omit<RequestPayload, 'hashId'> {
21 hashId: string;
22 connectorId?: number;
23 transactionId?: number;
24 idTag?: string;
25 }
26
27 export type BroadcastChannelResponsePayload = ResponsePayload;
28
29 export type MessageEvent = { data: BroadcastChannelRequest | BroadcastChannelResponse };