Fix build
[e-mobility-charging-stations-simulator.git] / src / charging-station / UIServiceWorkerBroadcastChannel.ts
index a94f2b31d263fa086153984c61d36a8ddffb4aa0..c64a7ccc2212d021189b373278ad8d5a804961bc 100644 (file)
@@ -1,5 +1,5 @@
-import BaseError from '../exception/BaseError';
-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';
@@ -20,12 +20,12 @@ export default class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChan
     if (this.isRequest(messageEvent.data)) {
       return;
     }
-    if (Array.isArray(messageEvent.data) === false) {
-      throw new BaseError('Worker broadcast channel protocol response is not an array');
-    }
+    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 {