From 90d13cedc44812e92c326efd58fd61d2b0ed4cf0 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Fri, 5 May 2023 10:42:45 +0200 Subject: [PATCH] openvidu-components: Wait for the promise resolved from unpublish method --- .../lib/services/openvidu/openvidu.service.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/openvidu/openvidu.service.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/openvidu/openvidu.service.ts index 35546f6b..e35a583c 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/openvidu/openvidu.service.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/openvidu/openvidu.service.ts @@ -312,13 +312,13 @@ export class OpenViduService { /** * @internal */ - private unpublish(publisher: Publisher): void { + private async unpublish(publisher: Publisher): Promise { if (!!publisher) { if (publisher === this.participantService.getMyCameraPublisher()) { this.publishAudioAux(this.participantService.getMyScreenPublisher(), this.participantService.isMyAudioActive()); - this.webcamSession.unpublish(publisher); + await this.webcamSession.unpublish(publisher); } else if (publisher === this.participantService.getMyScreenPublisher()) { - this.screenSession.unpublish(publisher); + await this.screenSession.unpublish(publisher); } } } @@ -334,9 +334,9 @@ export class OpenViduService { // Disabling webcam if (this.participantService.haveICameraAndScreenActive()) { await this.publishVideoAux(this.participantService.getMyCameraPublisher(), publish); - this.participantService.disableWebcamStream(); - this.unpublish(this.participantService.getMyCameraPublisher()); + await this.unpublish(this.participantService.getMyCameraPublisher()); this.publishAudioAux(this.participantService.getMyScreenPublisher(), publishAudio); + this.participantService.disableWebcamStream(); } else if (this.participantService.isOnlyMyScreenActive()) { // Enabling webcam const hasAudio = this.participantService.hasScreenAudioActive(); @@ -396,7 +396,7 @@ export class OpenViduService { if (this.participantService.haveICameraAndScreenActive()) { // Disabling screenShare this.participantService.disableScreenStream(); - this.unpublish(this.participantService.getMyScreenPublisher()); + await this.unpublish(this.participantService.getMyScreenPublisher()); } else if (this.participantService.isOnlyMyCameraActive()) { // I only have the camera published const hasAudioDevicesAvailable = this.deviceService.hasAudioDeviceAvailable(); @@ -432,7 +432,7 @@ export class OpenViduService { if (!this.participantService.isMyVideoActive()) { // Disabling webcam this.participantService.disableWebcamStream(); - this.unpublish(this.participantService.getMyCameraPublisher()); + await this.unpublish(this.participantService.getMyCameraPublisher()); } }); @@ -453,7 +453,7 @@ export class OpenViduService { // Disabling screenshare this.participantService.disableScreenStream(); - this.unpublish(this.participantService.getMyScreenPublisher()); + await this.unpublish(this.participantService.getMyScreenPublisher()); } }