X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2Focpp%2FOCPPResponseService.ts;h=ffcb888fe422bf35bb24549205ff4dfbc3ba09f5;hb=ada189a839743451d477d5b3bddc698f2634d799;hp=f45d1b43c076e758bdd1e86bbd15677186bbc7b6;hpb=e3822d6f1b40477f7308ad70c290ed2c4106c585;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index f45d1b43..ffcb888f 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -1,32 +1,25 @@ -import type ChargingStation from '../ChargingStation'; -import { JsonObject } from '../../types/JsonType'; +import { JsonType } from '../../types/JsonType'; import { RequestCommand } from '../../types/ocpp/Requests'; +import type ChargingStation from '../ChargingStation'; 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.hashId)) { - OCPPResponseService.instances.set(chargingStation.hashId, new this(chargingStation)); + public static getInstance(this: new () => T): T { + if (!OCPPResponseService.instance) { + OCPPResponseService.instance = new this(); } - return OCPPResponseService.instances.get(chargingStation.hashId) as T; + return OCPPResponseService.instance as T; } public abstract responseHandler( + chargingStation: ChargingStation, commandName: RequestCommand, - payload: JsonObject, - requestPayload: JsonObject + payload: JsonType, + requestPayload: JsonType ): Promise; }