X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=src%2Fcharging-station%2FUIServiceWorkerBroadcastChannel.ts;h=c64a7ccc2212d021189b373278ad8d5a804961bc;hb=18057587414006953ed112f315807d64ddb11bfd;hp=d50d514a469496159b5aad15f752bde3c3a0d031;hpb=db2336d96424096d5570606680824af180e33c3a;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/UIServiceWorkerBroadcastChannel.ts b/src/charging-station/UIServiceWorkerBroadcastChannel.ts index d50d514a..c64a7ccc 100644 --- a/src/charging-station/UIServiceWorkerBroadcastChannel.ts +++ b/src/charging-station/UIServiceWorkerBroadcastChannel.ts @@ -1,4 +1,5 @@ -import { BroadcastChannelResponse, MessageEvent } from '../types/WorkerBroadcastChannel'; +import type { ResponsePayload } from '../types/UIProtocol'; +import type { BroadcastChannelResponse, MessageEvent } from '../types/WorkerBroadcastChannel'; import logger from '../utils/Logger'; import type AbstractUIService from './ui-server/ui-services/AbstractUIService'; import WorkerBroadcastChannel from './WorkerBroadcastChannel'; @@ -19,9 +20,12 @@ export default class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChan if (this.isRequest(messageEvent.data)) { return; } + this.validateMessageEvent(messageEvent); const [uuid, responsePayload] = messageEvent.data as BroadcastChannelResponse; + // TODO: handle multiple responses for the same uuid + delete responsePayload.hashId; - this.uiService.sendResponse(uuid, responsePayload); + this.uiService.sendResponse(uuid, responsePayload as ResponsePayload); } private messageErrorHandler(messageEvent: MessageEvent): void {