Restructure UI server code to prepare it for issue #238
[e-mobility-charging-stations-simulator.git] / src / types / UIProtocol.ts
index 3e4d6232ba6202ca395fa57791fe8886b0f332e5..1756c0faff73b694a310f83bbf368c898aa8100f 100644 (file)
@@ -1,16 +1,26 @@
+import { JsonType } from './JsonType';
+
+export enum Protocol {
+  UI = 'ui',
+}
+
+export enum ApplicationProtocol {
+  HTTP = 'http',
+  WS = 'ws',
+}
 
 export enum ProtocolVersion {
   '0.0.1' = '0.0.1',
-  '0.0.2' = '0.0.2',
 }
 
 export enum ProtocolCommand {
   LIST_CHARGING_STATIONS = 'listChargingStations',
   START_TRANSACTION = 'startTransaction',
   STOP_TRANSACTION = 'stopTransaction',
-  UNKNOWN = 'unknown',
 }
 
-export type ProtocolRequest = [ProtocolVersion, ProtocolCommand, Record<string, unknown>];
+export type ProtocolRequest = [ProtocolCommand, JsonType];
 
-export type ProtocolRequestHandler = (payload: Record<string, unknown>) => Record<string, unknown> | Promise<Record<string, unknown>>;
+export type ProtocolRequestHandler = (
+  payload: JsonType
+) => void | Promise<void> | JsonType | Promise<JsonType>;