X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPIncomingRequestService.ts;h=06ccd312c0e970022c844f200fe3d0b631ef8c93;hb=b2abfe260a60aa7f1f2ca724b33eaec7dc08e511;hp=013cb62ad8235c002cf3e4d97fd65d3af5643412;hpb=60ddad538d0a01ece43f4f70928a9decf3531dda;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index 013cb62a..06ccd312 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -1,3 +1,5 @@ +import { AsyncResource } from 'async_hooks'; + import type { JSONSchemaType } from 'ajv'; import Ajv from 'ajv-draft-04'; import ajvFormats from 'ajv-formats'; @@ -14,9 +16,11 @@ const moduleName = 'OCPPIncomingRequestService'; export default abstract class OCPPIncomingRequestService { private static instance: OCPPIncomingRequestService | null = null; + protected asyncResource: AsyncResource; private ajv: Ajv; protected constructor() { + this.asyncResource = new AsyncResource(moduleName); this.ajv = new Ajv(); ajvFormats(this.ajv); this.incomingRequestHandler.bind(this); @@ -57,7 +61,7 @@ export default abstract class OCPPIncomingRequestService { schema: JSONSchemaType, payload: T ): boolean { - if (!chargingStation.getPayloadSchemaValidation()) { + if (chargingStation.getPayloadSchemaValidation() === false) { return true; } const validate = this.ajv.compile(schema);