X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftypes%2FUIProtocol.ts;h=2c5914953b2768bd94bdf836bb15c50fd40d1457;hb=4e3ff94d15f16cbeb7f65d14525bca7af3c551fd;hp=4ff499b48cfbbd52a03c5507709752782271d346;hpb=e3822d6f1b40477f7308ad70c290ed2c4106c585;p=e-mobility-charging-stations-simulator.git diff --git a/src/types/UIProtocol.ts b/src/types/UIProtocol.ts index 4ff499b4..2c591495 100644 --- a/src/types/UIProtocol.ts +++ b/src/types/UIProtocol.ts @@ -4,19 +4,41 @@ export enum Protocol { UI = 'ui', } +export enum ApplicationProtocol { + HTTP = 'http', + WS = 'ws', +} + export enum ProtocolVersion { '0.0.1' = '0.0.1', } -export enum ProtocolCommand { +export type ProtocolRequest = [string, ProcedureName, RequestPayload]; +export type ProtocolResponse = [string, ResponsePayload]; + +export type ProtocolRequestHandler = ( + uuid?: string, + payload?: RequestPayload +) => ResponsePayload | Promise; + +export enum ProcedureName { LIST_CHARGING_STATIONS = 'listChargingStations', + START_CHARGING_STATION = 'startChargingStation', + STOP_CHARGING_STATION = 'stopChargingStation', START_TRANSACTION = 'startTransaction', STOP_TRANSACTION = 'stopTransaction', - UNKNOWN = 'unknown', + START_SIMULATOR = 'startSimulator', + STOP_SIMULATOR = 'stopSimulator', +} +export interface RequestPayload extends JsonObject { + hashId?: string; } -export type ProtocolRequest = [ProtocolCommand, JsonObject]; +export enum ResponseStatus { + SUCCESS = 'success', + FAILURE = 'failure', +} -export type ProtocolRequestHandler = ( - payload: JsonObject -) => void | Promise | JsonObject | Promise; +export interface ResponsePayload extends JsonObject { + status: ResponseStatus; +}