X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2Fui-server%2FAbstractUIServer.ts;h=9a19d39d9a6d29550c614b937f14fd18bcb514e3;hb=60ddad538d0a01ece43f4f70928a9decf3531dda;hp=432c91e7140916089fc393430ae1922e5e2baf31;hpb=8114d10e3893e96bb725ce2fca9744429ee4b75b;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ui-server/AbstractUIServer.ts b/src/charging-station/ui-server/AbstractUIServer.ts index 432c91e7..9a19d39d 100644 --- a/src/charging-station/ui-server/AbstractUIServer.ts +++ b/src/charging-station/ui-server/AbstractUIServer.ts @@ -1,22 +1,47 @@ -import { Server as HttpServer } from 'http'; +import type { Server as HttpServer } from 'http'; -import WebSocket from 'ws'; +import type WebSocket from 'ws'; -import { ProtocolVersion } from '../../types/UIProtocol'; -import AbstractUIService from './ui-services/AbstractUIService'; +import type { ChargingStationData } from '../../types/ChargingStationWorker'; +import type { + ProcedureName, + ProtocolRequest, + ProtocolResponse, + ProtocolVersion, + RequestPayload, + ResponsePayload, +} from '../../types/UIProtocol'; +import type AbstractUIService from './ui-services/AbstractUIService'; export abstract class AbstractUIServer { - public readonly chargingStations: Set; - protected readonly uiServices: Map; + public readonly chargingStations: Map; protected server: WebSocket.Server | HttpServer; + protected readonly uiServices: Map; public constructor() { - this.chargingStations = new Set(); + this.chargingStations = new Map(); this.uiServices = new Map(); } + public buildProtocolRequest( + id: string, + procedureName: ProcedureName, + requestPayload: RequestPayload + ): ProtocolRequest { + return [id, procedureName, requestPayload]; + } + + public buildProtocolResponse(id: string, responsePayload: ResponsePayload): ProtocolResponse { + return [id, responsePayload]; + } + public abstract start(): void; public abstract stop(): void; - public abstract sendResponse(message: string): void; - public abstract logPrefix(): string; + public abstract sendRequest(request: ProtocolRequest): void; + public abstract sendResponse(response: ProtocolResponse): void; + public abstract logPrefix( + moduleName?: string, + methodName?: string, + prefixSuffix?: string + ): string; }