Commit | Line | Data |
---|---|---|
6c1761d4 | 1 | import type { Server as HttpServer } from 'http'; |
8114d10e | 2 | |
6c1761d4 | 3 | import type WebSocket from 'ws'; |
fe94fce0 | 4 | |
6c1761d4 JB |
5 | import type { ChargingStationData } from '../../types/ChargingStationWorker'; |
6 | import type { | |
852a4c5f JB |
7 | ProcedureName, |
8 | ProtocolRequest, | |
9 | ProtocolResponse, | |
10 | ProtocolVersion, | |
11 | RequestPayload, | |
12 | ResponsePayload, | |
13 | } from '../../types/UIProtocol'; | |
db2336d9 | 14 | import type AbstractUIService from './ui-services/AbstractUIService'; |
8114d10e | 15 | |
fe94fce0 | 16 | export abstract class AbstractUIServer { |
32de5a57 | 17 | public readonly chargingStations: Map<string, ChargingStationData>; |
0d8140bd | 18 | protected server: WebSocket.Server | HttpServer; |
5e3cb728 | 19 | protected readonly uiServices: Map<ProtocolVersion, AbstractUIService>; |
fe94fce0 JB |
20 | |
21 | public constructor() { | |
32de5a57 | 22 | this.chargingStations = new Map<string, ChargingStationData>(); |
fe94fce0 JB |
23 | this.uiServices = new Map<ProtocolVersion, AbstractUIService>(); |
24 | } | |
25 | ||
852a4c5f JB |
26 | public buildProtocolRequest( |
27 | id: string, | |
28 | procedureName: ProcedureName, | |
29 | requestPayload: RequestPayload | |
5e3cb728 JB |
30 | ): ProtocolRequest { |
31 | return [id, procedureName, requestPayload]; | |
852a4c5f JB |
32 | } |
33 | ||
5e3cb728 JB |
34 | public buildProtocolResponse(id: string, responsePayload: ResponsePayload): ProtocolResponse { |
35 | return [id, responsePayload]; | |
852a4c5f JB |
36 | } |
37 | ||
fe94fce0 JB |
38 | public abstract start(): void; |
39 | public abstract stop(): void; | |
5e3cb728 JB |
40 | public abstract sendRequest(request: ProtocolRequest): void; |
41 | public abstract sendResponse(response: ProtocolResponse): void; | |
42 | public abstract logPrefix( | |
43 | moduleName?: string, | |
44 | methodName?: string, | |
45 | prefixSuffix?: string | |
46 | ): string; | |
fe94fce0 | 47 | } |