X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPResponseService.ts;h=e838bd9fb1d4ae2280ca08d2e9516917ffac37fc;hb=dc6617020896c78ee5b3d4ef2513c98b4d61f06f;hp=c0dd3f767ea14ff8546195556c48daf3aec3dc0c;hpb=9f2e313013116428f5bce2be59e2f5c07502c026;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index c0dd3f76..e838bd9f 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -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 = new Map(); + private static readonly instances: Map = new Map< + string, + OCPPResponseService + >(); + protected readonly chargingStation: ChargingStation; protected constructor(chargingStation: ChargingStation) { this.chargingStation = chargingStation; } - public static getInstance(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( + 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; + public abstract responseHandler( + commandName: RequestCommand, + payload: JsonType, + requestPayload: JsonType + ): Promise; }