| 1 | import { ProtocolCommand, ProtocolVersion } from '../../../types/UIProtocol'; |
| 2 | |
| 3 | import WebSocketServer from '../../WebSocketServer'; |
| 4 | |
| 5 | export default abstract class AbstractUIService { |
| 6 | public readonly chargingStations: Set<string>; |
| 7 | protected readonly webSocketServer: WebSocketServer; |
| 8 | |
| 9 | constructor(webSocketServer: WebSocketServer) { |
| 10 | this.chargingStations = new Set<string>(); |
| 11 | this.webSocketServer = webSocketServer; |
| 12 | } |
| 13 | |
| 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>; |
| 23 | } |