refactor: unflag worker startup at the right time on worker set
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPResponseService.ts
index b15b7cd6ad2a397febed5205014a5a26c4f57cf1..7934500ed3ebd7612cfb05ad58b0c68699396dc1 100644 (file)
@@ -31,11 +31,14 @@ export abstract class OCPPResponseService {
       multipleOfPrecision: 2,
     });
     ajvFormats(this.ajv);
-    this.responseHandler = this.responseHandler.bind(this) as (
+    this.responseHandler = this.responseHandler.bind(this) as <
+      ReqType extends JsonType,
+      ResType extends JsonType,
+    >(
       chargingStation: ChargingStation,
       commandName: RequestCommand,
-      payload: JsonType,
-      requestPayload: JsonType,
+      payload: ResType,
+      requestPayload: ReqType,
     ) => Promise<void>;
     this.validateResponsePayload = this.validateResponsePayload.bind(this) as <T extends JsonType>(
       chargingStation: ChargingStation,
@@ -70,7 +73,7 @@ export abstract class OCPPResponseService {
       validate.errors,
     );
     throw new OCPPError(
-      OCPPServiceUtils.ajvErrorsToErrorType(validate.errors),
+      OCPPServiceUtils.ajvErrorsToErrorType(validate.errors!),
       'Response PDU is invalid',
       commandName,
       JSON.stringify(validate.errors, null, 2),
@@ -81,10 +84,10 @@ export abstract class OCPPResponseService {
     /* This is intentional */
   }
 
-  public abstract responseHandler(
+  public abstract responseHandler<ReqType extends JsonType, ResType extends JsonType>(
     chargingStation: ChargingStation,
     commandName: RequestCommand,
-    payload: JsonType,
-    requestPayload: JsonType,
+    payload: ResType,
+    requestPayload: ReqType,
   ): Promise<void>;
 }