Commit | Line | Data |
---|---|---|
ee0f106b JB |
1 | import { ProtocolCommand, ProtocolVersion } from '../../../types/UIProtocol'; |
2 | ||
8244f5f0 JB |
3 | import WebSocketServer from '../../WebSocketServer'; |
4 | ||
5 | export default abstract class AbstractUIService { | |
ee0f106b | 6 | public readonly chargingStations: Set<string>; |
8244f5f0 JB |
7 | protected readonly webSocketServer: WebSocketServer; |
8 | ||
9 | constructor(webSocketServer: WebSocketServer) { | |
ee0f106b | 10 | this.chargingStations = new Set<string>(); |
8244f5f0 JB |
11 | this.webSocketServer = webSocketServer; |
12 | } | |
13 | ||
ee0f106b JB |
14 | protected buildProtocolMessage( |
15 | version: ProtocolVersion, | |
16 | command: ProtocolCommand, | |
17 | payload: Record<string, unknown>, | |
18 | ): string { | |
19 | return JSON.stringify([version, command, payload]); | |
20 | } | |
21 | ||
22 | abstract handleMessage(version: ProtocolVersion, command: ProtocolCommand, payload: Record<string, unknown>): Promise<void>; | |
8244f5f0 | 23 | } |