Commit | Line | Data |
---|---|---|
32de5a57 | 1 | import { JsonObject, JsonType } from './JsonType'; |
d1888640 | 2 | |
4198ad5c JB |
3 | export enum Protocol { |
4 | UI = 'ui', | |
5 | } | |
8244f5f0 | 6 | |
675fa8e3 JB |
7 | export enum ApplicationProtocol { |
8 | HTTP = 'http', | |
9 | WS = 'ws', | |
10 | } | |
11 | ||
8244f5f0 JB |
12 | export enum ProtocolVersion { |
13 | '0.0.1' = '0.0.1', | |
8244f5f0 JB |
14 | } |
15 | ||
32de5a57 | 16 | export enum ProcedureName { |
ee0f106b | 17 | LIST_CHARGING_STATIONS = 'listChargingStations', |
8244f5f0 JB |
18 | START_TRANSACTION = 'startTransaction', |
19 | STOP_TRANSACTION = 'stopTransaction', | |
32de5a57 LM |
20 | START_SIMULATOR = 'startSimulator', |
21 | STOP_SIMULATOR = 'stopSimulator', | |
8244f5f0 JB |
22 | } |
23 | ||
32de5a57 LM |
24 | export enum ResponseStatus { |
25 | SUCCESS = 'success', | |
26 | FAILURE = 'failure', | |
27 | } | |
28 | ||
29 | export interface ResponsePayload extends JsonObject { | |
30 | status: ResponseStatus; | |
31 | } | |
32 | ||
33 | export type ProtocolRequest = [string, ProcedureName, JsonType]; | |
34 | export type ProtocolResponse = [string, ResponsePayload]; | |
8244f5f0 | 35 | |
e7aeea18 | 36 | export type ProtocolRequestHandler = ( |
5cc4b63b | 37 | payload: JsonType |
32de5a57 | 38 | ) => void | Promise<void> | ResponsePayload | Promise<ResponsePayload>; |