Vue UI + UI server
[e-mobility-charging-stations-simulator.git] / src / types / UIProtocol.ts
1 import { JsonObject, JsonType } from './JsonType';
2
3 export enum Protocol {
4 UI = 'ui',
5 }
6
7 export enum ApplicationProtocol {
8 HTTP = 'http',
9 WS = 'ws',
10 }
11
12 export enum ProtocolVersion {
13 '0.0.1' = '0.0.1',
14 }
15
16 export enum ProcedureName {
17 LIST_CHARGING_STATIONS = 'listChargingStations',
18 START_TRANSACTION = 'startTransaction',
19 STOP_TRANSACTION = 'stopTransaction',
20 START_SIMULATOR = 'startSimulator',
21 STOP_SIMULATOR = 'stopSimulator',
22 }
23
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];
35
36 export type ProtocolRequestHandler = (
37 payload: JsonType
38 ) => void | Promise<void> | ResponsePayload | Promise<ResponsePayload>;