X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPIncomingRequestService.ts;h=80857cc795b7941bb5a2b8e571c28dc2e3a73661;hb=a7529a86c56c90db6c508ba453de4cedc17a3405;hp=de036e707237bf1393f537abddd62b58cebd0e1f;hpb=2896e06dc8d72adf7150b23c941079f622f6f37c;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index de036e70..80857cc7 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -1,4 +1,4 @@ -import { AsyncResource } from 'async_hooks'; +import { AsyncResource } from 'node:async_hooks'; import Ajv, { type JSONSchemaType } from 'ajv'; import ajvFormats from 'ajv-formats'; @@ -14,7 +14,7 @@ import type { JsonType, OCPPVersion, } from '../../types'; -import { logger } from '../../utils/Logger'; +import { logger } from '../../utils'; const moduleName = 'OCPPIncomingRequestService'; @@ -32,8 +32,20 @@ export abstract class OCPPIncomingRequestService extends AsyncResource { multipleOfPrecision: 2, }); ajvFormats(this.ajv); - this.incomingRequestHandler.bind(this); - this.validateIncomingRequestPayload.bind(this); + this.incomingRequestHandler = this.incomingRequestHandler.bind(this) as ( + chargingStation: ChargingStation, + messageId: string, + commandName: IncomingRequestCommand, + commandPayload: JsonType + ) => Promise; + this.validateIncomingRequestPayload = this.validateIncomingRequestPayload.bind(this) as < + T extends JsonType + >( + chargingStation: ChargingStation, + commandName: IncomingRequestCommand, + schema: JSONSchemaType, + payload: T + ) => boolean; } public static getInstance(this: new () => T): T { @@ -90,8 +102,8 @@ export abstract class OCPPIncomingRequestService extends AsyncResource { } protected handleRequestClearCache(chargingStation: ChargingStation): ClearCacheResponse { - chargingStation.authorizedTagsCache.deleteAuthorizedTags( - ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo) + chargingStation.idTagsCache.deleteIdTags( + ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo) ); return OCPPConstants.OCPP_RESPONSE_ACCEPTED; }