X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2Focpp%2FOCPPResponseService.ts;h=19088aab293442dc564d918bbe364730414d3a1c;hb=9d7484a4667898757b7c23be3dec7458c337cb84;hp=2fa0112c70c6d42fc29958da64007576824b6285;hpb=e7aeea18e189dd087c8f951cf77a253e2818ae90;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index 2fa0112c..19088aab 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -3,29 +3,23 @@ import { JsonType } from '../../types/JsonType'; import { RequestCommand } from '../../types/ocpp/Requests'; export default abstract class OCPPResponseService { - private static readonly instances: Map = new Map< - string, - OCPPResponseService - >(); - protected readonly chargingStation: ChargingStation; + private static instance: OCPPResponseService | null = null; - protected constructor(chargingStation: ChargingStation) { - this.chargingStation = chargingStation; + protected constructor() { + // This is intentional } - 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 () => T): T { + if (!OCPPResponseService.instance) { + OCPPResponseService.instance = new this(); } - return OCPPResponseService.instances.get(chargingStation.id) as T; + return OCPPResponseService.instance as T; } - public abstract handleResponse( + public abstract responseHandler( + chargingStation: ChargingStation, commandName: RequestCommand, - payload: JsonType | string, + payload: JsonType, requestPayload: JsonType ): Promise; }