+ private static instance: OCPPIncomingRequestService | null = null;
+ protected asyncResource: AsyncResource;
+ private readonly version: OCPPVersion;
+ private readonly ajv: Ajv;
+ protected abstract jsonSchemas: Map<IncomingRequestCommand, JSONSchemaType<JsonObject>>;
+
+ protected constructor(version: OCPPVersion) {
+ this.version = version;
+ this.ajv = new Ajv({
+ keywords: ['javaType'],
+ multipleOfPrecision: 2,
+ });
+ ajvFormats(this.ajv);
+ this.asyncResource = new AsyncResource(moduleName);
+ this.incomingRequestHandler.bind(this);
+ this.validateIncomingRequestPayload.bind(this);
+ }
+
+ public static getInstance<T extends OCPPIncomingRequestService>(this: new () => T): T {
+ if (OCPPIncomingRequestService.instance === null) {
+ OCPPIncomingRequestService.instance = new this();
+ }
+ return OCPPIncomingRequestService.instance as T;
+ }