From: Jérôme Benoit Date: Mon, 22 Aug 2022 09:30:33 +0000 (+0200) Subject: Bound most called methods in the OCPP stack X-Git-Tag: v1.1.66~29 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9952c548347c27a4006eb765659d7bc05c400260;p=e-mobility-charging-stations-simulator.git Bound most called methods in the OCPP stack Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index eb5514ef..e03a2e0b 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -276,6 +276,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer ) as JSONSchemaType, ], ]); + this.validatePayload.bind(this); } public async incomingRequestHandler( diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 69ff5c85..1f8e58d5 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -140,6 +140,8 @@ export default class OCPP16RequestService extends OCPPRequestService { ) as JSONSchemaType, ], ]); + this.buildRequestPayload.bind(this); + this.validatePayload.bind(this); } public async requestHandler( diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 56ad9586..04431203 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -165,6 +165,7 @@ export default class OCPP16ResponseService extends OCPPResponseService { ) as JSONSchemaType, ], ]); + this.validatePayload.bind(this); } public async responseHandler( diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index 23d0ffdd..2990b489 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -19,6 +19,8 @@ export default abstract class OCPPIncomingRequestService { protected constructor() { this.ajv = new Ajv(); ajvFormats(this.ajv); + this.incomingRequestHandler.bind(this); + this.validateIncomingRequestPayload.bind(this); } public static getInstance(this: new () => T): T { diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 6f4e47be..0380e664 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -34,11 +34,14 @@ export default abstract class OCPPRequestService { protected constructor(ocppResponseService: OCPPResponseService) { this.ocppResponseService = ocppResponseService; + this.ajv = new Ajv(); + ajvFormats(this.ajv); this.requestHandler.bind(this); this.sendResponse.bind(this); this.sendError.bind(this); - this.ajv = new Ajv(); - ajvFormats(this.ajv); + this.internalSendMessage.bind(this); + this.buildMessageToSend.bind(this); + this.validateRequestPayload.bind(this); } public static getInstance( diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index 624659ae..94a943d7 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -18,6 +18,8 @@ export default abstract class OCPPResponseService { protected constructor() { this.ajv = new Ajv(); ajvFormats(this.ajv); + this.responseHandler.bind(this); + this.validateResponsePayload.bind(this); } public static getInstance(this: new () => T): T {