Add status notification support to trigger message OCPP command
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPResponseService.ts
index c0dd3f767ea14ff8546195556c48daf3aec3dc0c..e838bd9fb1d4ae2280ca08d2e9516917ffac37fc 100644 (file)
@@ -3,19 +3,30 @@ import { JsonType } from '../../types/JsonType';
 import { RequestCommand } from '../../types/ocpp/Requests';
 
 export default abstract class OCPPResponseService {
-  private static readonly instances: Map<string, OCPPResponseService> = new Map<string, OCPPResponseService>();
+  private static readonly instances: Map<string, OCPPResponseService> = new Map<
+    string,
+    OCPPResponseService
+  >();
+
   protected readonly chargingStation: ChargingStation;
 
   protected constructor(chargingStation: ChargingStation) {
     this.chargingStation = chargingStation;
   }
 
-  public static getInstance<T extends OCPPResponseService>(this: new (chargingStation: ChargingStation) => T, chargingStation: ChargingStation): T {
-    if (!OCPPResponseService.instances.has(chargingStation.id)) {
-      OCPPResponseService.instances.set(chargingStation.id, new this(chargingStation));
+  public static getInstance<T extends OCPPResponseService>(
+    this: new (chargingStation: ChargingStation) => T,
+    chargingStation: ChargingStation
+  ): T {
+    if (!OCPPResponseService.instances.has(chargingStation.hashId)) {
+      OCPPResponseService.instances.set(chargingStation.hashId, new this(chargingStation));
     }
-    return OCPPResponseService.instances.get(chargingStation.id) as T;
+    return OCPPResponseService.instances.get(chargingStation.hashId) as T;
   }
 
-  public abstract handleResponse(commandName: RequestCommand, payload: JsonType | string, requestPayload: JsonType): Promise<void>;
+  public abstract responseHandler(
+    commandName: RequestCommand,
+    payload: JsonType,
+    requestPayload: JsonType
+  ): Promise<void>;
 }