- this.validateMessageEvent(messageEvent);
- const [uuid, responsePayload] = messageEvent.data as BroadcastChannelResponse;
+ const [uuid, responsePayload] = this.validateMessageEvent(messageEvent)
+ .data as BroadcastChannelResponse;
+ if (this.responses.has(uuid) === false) {
+ this.responses.set(uuid, {
+ responsesExpected: this.uiService.getBroadcastChannelExpectedResponses(uuid),
+ responsesReceived: 1,
+ responses: [responsePayload],
+ });
+ } else if (
+ this.responses.get(uuid)?.responsesReceived + 1 <
+ this.responses.get(uuid)?.responsesExpected
+ ) {
+ this.responses.get(uuid).responsesReceived++;
+ this.responses.get(uuid).responses.push(responsePayload);
+ } else if (
+ this.responses.get(uuid)?.responsesReceived + 1 ===
+ this.responses.get(uuid)?.responsesExpected
+ ) {
+ this.responses.get(uuid).responses.push(responsePayload);
+ this.uiService.sendResponse(uuid, this.buildResponsePayload(uuid));
+ this.responses.delete(uuid);
+ this.uiService.deleteBroadcastChannelRequest(uuid);
+ }
+ }