const [uuid, command, requestPayload] = messageEvent.data as BroadcastChannelRequest;
- if (
- requestPayload?.hashId === undefined &&
- requestPayload?.hashIds?.includes(this.chargingStation.stationInfo.hashId) === false
- ) {
- return;
- }
- if (
- requestPayload?.hashIds === undefined &&
- requestPayload?.hashId !== this.chargingStation.stationInfo.hashId
- ) {
- return;
- }
- if (requestPayload?.hashId !== undefined) {
- logger.warn(
- `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' instead`
- );
+ if (requestPayload?.hashIds !== undefined || requestPayload?.hashId !== undefined) {
+ if (
+ requestPayload?.hashId === undefined &&
+ requestPayload?.hashIds?.includes(this.chargingStation.stationInfo.hashId) === false
+ ) {
+ return;
+ }
+ if (
+ requestPayload?.hashIds === undefined &&
+ requestPayload?.hashId !== this.chargingStation.stationInfo.hashId
+ ) {
+ return;
+ }
+ if (requestPayload?.hashId !== undefined) {
+ logger.warn(
+ `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' instead`
+ );
+ }
}
let responsePayload: BroadcastChannelResponsePayload;
import { BroadcastChannel } from 'worker_threads';
import BaseError from '../exception/BaseError';
+import type { JsonType } from '../types/JsonType';
import type {
BroadcastChannelRequest,
BroadcastChannelResponse,
this.postMessage(response);
}
- protected isRequest(message: any): boolean {
+ protected isRequest(message: JsonType[]): boolean {
return Array.isArray(message) && message.length === 3;
}
- protected isResponse(message: any): boolean {
+ protected isResponse(message: JsonType[]): boolean {
return Array.isArray(message) && message.length === 2;
}