| 1 | import type { 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 interface BroadcastChannelResponsePayload extends ResponsePayload { |
| 38 | hashId: string; |
| 39 | } |
| 40 | |
| 41 | export type MessageEvent = { data: BroadcastChannelRequest | BroadcastChannelResponse }; |