+ if (
+ requestPayload?.hashIds === undefined &&
+ requestPayload?.hashId !== this.chargingStation.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;
+ let commandResponse: CommandResponse;
+ try {
+ commandResponse = await this.commandHandler(command, requestPayload);
+ if (commandResponse === undefined) {
+ responsePayload = {
+ hashId: this.chargingStation.hashId,
+ status: ResponseStatus.SUCCESS,
+ };
+ } else {
+ responsePayload = {
+ hashId: this.chargingStation.hashId,
+ status: this.commandResponseToResponseStatus(commandResponse),
+ };
+ }
+ } catch (error) {
+ logger.error(
+ `${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: Handle request error:`,
+ error
+ );
+ responsePayload = {
+ hashId: this.chargingStation.hashId,
+ status: ResponseStatus.FAILURE,
+ command,
+ requestPayload,
+ commandResponse,
+ errorMessage: (error as Error).message,
+ errorStack: (error as Error).stack,
+ };
+ }
+ this.sendResponse([uuid, responsePayload]);
+ }
+
+ private messageErrorHandler(messageEvent: MessageEvent): void {
+ logger.error(
+ `${this.chargingStation.logPrefix()} ${moduleName}.messageErrorHandler: Error at handling message:`,
+ { messageEvent, messageEventData: messageEvent.data }
+ );
+ }