From 95e5e977da11729f00973907b134b5d92cd9dc36 Mon Sep 17 00:00:00 2001 From: csantosm <4a.santos@gmail.com> Date: Wed, 6 Jul 2022 00:02:48 +0200 Subject: [PATCH] openvidu-components: Fixed race condition with session initialization When prejoin component is disabled, the Session component was initialized before the videoconference component initialization had finished --- .../videoconference/videoconference.component.html | 2 +- .../videoconference/videoconference.component.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/videoconference/videoconference.component.html b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/videoconference/videoconference.component.html index 8ce64b65..c0ba4c90 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/videoconference/videoconference.component.html +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/videoconference/videoconference.component.html @@ -15,7 +15,7 @@
- + diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/videoconference/videoconference.component.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/videoconference/videoconference.component.ts index 0199c1ac..ceb9c4f1 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/videoconference/videoconference.component.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/videoconference/videoconference.component.ts @@ -401,6 +401,11 @@ export class VideoconferenceComponent implements OnInit, OnDestroy, AfterViewIni */ showPrejoin: boolean = true; + /** + * @internal + */ + isSessionInitialized: boolean = false; + /** * @internal */ @@ -431,17 +436,12 @@ export class VideoconferenceComponent implements OnInit, OnDestroy, AfterViewIni this.subscribeToVideconferenceDirectives(); await this.deviceSrv.forceInitDevices(); const nickname = this.externalParticipantName || this.storageSrv.getNickname() || `OpenVidu_User${Math.floor(Math.random() * 100)}`; - const props: ParticipantProperties = { - local: true, - nickname - }; - this.participantService.initLocalParticipant(props); + this.participantService.initLocalParticipant({local: true, nickname}); this.openviduService.initialize(); - if (this.deviceSrv.hasVideoDeviceAvailable() || this.deviceSrv.hasAudioDeviceAvailable()) { await this.initwebcamPublisher(); } - + this.isSessionInitialized = true; this.onParticipantCreated.emit(this.participantService.getLocalParticipant()); }