Bound most called methods in the OCPP stack
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 22 Aug 2022 09:30:33 +0000 (11:30 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 22 Aug 2022 09:30:33 +0000 (11:30 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/OCPPIncomingRequestService.ts
src/charging-station/ocpp/OCPPRequestService.ts
src/charging-station/ocpp/OCPPResponseService.ts

index eb5514efaa0760a666122b5c04b9cad63e736cbb..e03a2e0b115252e7a1550063a401240c061803f5 100644 (file)
@@ -276,6 +276,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
         ) as JSONSchemaType<OCPP16TriggerMessageRequest>,
       ],
     ]);
+    this.validatePayload.bind(this);
   }
 
   public async incomingRequestHandler(
index 69ff5c851f61f142b7c31438e89896e9424a024d..1f8e58d5748c1db5cdf0e338ef08597b2033234f 100644 (file)
@@ -140,6 +140,8 @@ export default class OCPP16RequestService extends OCPPRequestService {
         ) as JSONSchemaType<OCPP16StopTransactionRequest>,
       ],
     ]);
+    this.buildRequestPayload.bind(this);
+    this.validatePayload.bind(this);
   }
 
   public async requestHandler<Request extends JsonType, Response extends JsonType>(
index 56ad958658ed68c2249e8f9580317aa90af91254..04431203934f17a13f499ad4c328f2d5e838858f 100644 (file)
@@ -165,6 +165,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
         ) as JSONSchemaType<DiagnosticsStatusNotificationResponse>,
       ],
     ]);
+    this.validatePayload.bind(this);
   }
 
   public async responseHandler(
index 23d0ffdd6d377737fb771f89f001518e6447fe09..2990b489d7e7b1982e7751e2b9ba39ad63de4a7b 100644 (file)
@@ -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<T extends OCPPIncomingRequestService>(this: new () => T): T {
index 6f4e47be04864463f34b6b89fa65bceae9cf614c..0380e6646402bd801a22ba92ceef19305f01e30b 100644 (file)
@@ -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<T extends OCPPRequestService>(
index 624659aeec5e18cb78a6c5dd31d498ce2648489d..94a943d7c5439ed7f77936d3e464fa6b81443eab 100644 (file)
@@ -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<T extends OCPPResponseService>(this: new () => T): T {