openvidu-components: Wait for the promise resolved from unpublish method

pull/803/head
Carlos Santos 2023-05-05 10:42:45 +02:00
parent 90acd8682c
commit 90d13cedc4
1 changed files with 8 additions and 8 deletions

View File

@ -312,13 +312,13 @@ export class OpenViduService {
/** /**
* @internal * @internal
*/ */
private unpublish(publisher: Publisher): void { private async unpublish(publisher: Publisher): Promise<void> {
if (!!publisher) { if (!!publisher) {
if (publisher === this.participantService.getMyCameraPublisher()) { if (publisher === this.participantService.getMyCameraPublisher()) {
this.publishAudioAux(this.participantService.getMyScreenPublisher(), this.participantService.isMyAudioActive()); this.publishAudioAux(this.participantService.getMyScreenPublisher(), this.participantService.isMyAudioActive());
this.webcamSession.unpublish(publisher); await this.webcamSession.unpublish(publisher);
} else if (publisher === this.participantService.getMyScreenPublisher()) { } else if (publisher === this.participantService.getMyScreenPublisher()) {
this.screenSession.unpublish(publisher); await this.screenSession.unpublish(publisher);
} }
} }
} }
@ -334,9 +334,9 @@ export class OpenViduService {
// Disabling webcam // Disabling webcam
if (this.participantService.haveICameraAndScreenActive()) { if (this.participantService.haveICameraAndScreenActive()) {
await this.publishVideoAux(this.participantService.getMyCameraPublisher(), publish); await this.publishVideoAux(this.participantService.getMyCameraPublisher(), publish);
this.participantService.disableWebcamStream(); await this.unpublish(this.participantService.getMyCameraPublisher());
this.unpublish(this.participantService.getMyCameraPublisher());
this.publishAudioAux(this.participantService.getMyScreenPublisher(), publishAudio); this.publishAudioAux(this.participantService.getMyScreenPublisher(), publishAudio);
this.participantService.disableWebcamStream();
} else if (this.participantService.isOnlyMyScreenActive()) { } else if (this.participantService.isOnlyMyScreenActive()) {
// Enabling webcam // Enabling webcam
const hasAudio = this.participantService.hasScreenAudioActive(); const hasAudio = this.participantService.hasScreenAudioActive();
@ -396,7 +396,7 @@ export class OpenViduService {
if (this.participantService.haveICameraAndScreenActive()) { if (this.participantService.haveICameraAndScreenActive()) {
// Disabling screenShare // Disabling screenShare
this.participantService.disableScreenStream(); this.participantService.disableScreenStream();
this.unpublish(this.participantService.getMyScreenPublisher()); await this.unpublish(this.participantService.getMyScreenPublisher());
} else if (this.participantService.isOnlyMyCameraActive()) { } else if (this.participantService.isOnlyMyCameraActive()) {
// I only have the camera published // I only have the camera published
const hasAudioDevicesAvailable = this.deviceService.hasAudioDeviceAvailable(); const hasAudioDevicesAvailable = this.deviceService.hasAudioDeviceAvailable();
@ -432,7 +432,7 @@ export class OpenViduService {
if (!this.participantService.isMyVideoActive()) { if (!this.participantService.isMyVideoActive()) {
// Disabling webcam // Disabling webcam
this.participantService.disableWebcamStream(); this.participantService.disableWebcamStream();
this.unpublish(this.participantService.getMyCameraPublisher()); await this.unpublish(this.participantService.getMyCameraPublisher());
} }
}); });
@ -453,7 +453,7 @@ export class OpenViduService {
// Disabling screenshare // Disabling screenshare
this.participantService.disableScreenStream(); this.participantService.disableScreenStream();
this.unpublish(this.participantService.getMyScreenPublisher()); await this.unpublish(this.participantService.getMyScreenPublisher());
} }
} }