Fix Json type definition naming
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPResponseService.ts
CommitLineData
9f2e3130 1import type ChargingStation from '../ChargingStation';
e3822d6f 2import { JsonObject } from '../../types/JsonType';
c0560973
JB
3import { RequestCommand } from '../../types/ocpp/Requests';
4
5export default abstract class OCPPResponseService {
e7aeea18
JB
6 private static readonly instances: Map<string, OCPPResponseService> = new Map<
7 string,
8 OCPPResponseService
9 >();
10068088 10
9f2e3130 11 protected readonly chargingStation: ChargingStation;
c0560973 12
9f2e3130 13 protected constructor(chargingStation: ChargingStation) {
c0560973
JB
14 this.chargingStation = chargingStation;
15 }
16
e7aeea18
JB
17 public static getInstance<T extends OCPPResponseService>(
18 this: new (chargingStation: ChargingStation) => T,
19 chargingStation: ChargingStation
20 ): T {
3f94cab5
JB
21 if (!OCPPResponseService.instances.has(chargingStation.hashId)) {
22 OCPPResponseService.instances.set(chargingStation.hashId, new this(chargingStation));
9f2e3130 23 }
3f94cab5 24 return OCPPResponseService.instances.get(chargingStation.hashId) as T;
9f2e3130
JB
25 }
26
f7f98c68 27 public abstract responseHandler(
e7aeea18 28 commandName: RequestCommand,
e3822d6f
JB
29 payload: JsonObject,
30 requestPayload: JsonObject
e7aeea18 31 ): Promise<void>;
c0560973 32}