diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts index ed376e1d..9851e390 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts @@ -1,4 +1,14 @@ -import { ChangeDetectionStrategy, Component, ContentChild, EventEmitter, HostListener, Input, OnInit, Output, TemplateRef, ViewChild } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + ContentChild, + EventEmitter, + HostListener, + OnInit, + Output, + TemplateRef, + ViewChild +} from '@angular/core'; import { Subscriber, Session, StreamEvent, StreamPropertyChangedEvent, SessionDisconnectedEvent, ConnectionEvent } from 'openvidu-browser'; import { VideoType } from '../../models/video-type.model'; @@ -29,7 +39,6 @@ export class SessionComponent implements OnInit { @ContentChild('panel', { read: TemplateRef }) panelTemplate: TemplateRef; @ContentChild('layout', { read: TemplateRef }) layoutTemplate: TemplateRef; - @Input() tokens: { webcam: string; screen: string }; @Output() _session = new EventEmitter(); @Output() _publisher = new EventEmitter(); @Output() _error = new EventEmitter(); @@ -59,7 +68,7 @@ export class SessionComponent implements OnInit { protected chatService: ChatService, protected tokenService: TokenService, protected layoutService: LayoutService, - protected menuService: SidenavMenuService, + protected menuService: SidenavMenuService ) { this.log = this.loggerSrv.get('SessionComponent'); } @@ -85,7 +94,6 @@ export class SessionComponent implements OnInit { } async ngOnInit() { - this.session = this.openviduService.getWebcamSession(); this.sessionScreen = this.openviduService.getScreenSession(); this.subscribeToConnectionCreatedAndDestroyed(); @@ -96,9 +104,6 @@ export class SessionComponent implements OnInit { this.chatService.subscribeToChat(); this.subscribeToReconnection(); - this.tokenService.setWebcamToken(this.tokens.webcam); - this.tokenService.setScreenToken(this.tokens.screen); - await this.connectToSession(); // Workaround, firefox does not have audio when publisher join with muted camera // if (this.platformService.isFirefox() && !this.localUserService.hasCameraVideoActive()) { 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 1a30fc93..6e785bb5 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 @@ -14,8 +14,8 @@ {{ errorMessage }} -
- +
+ 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 590b2da7..e3d19ff0 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 @@ -32,6 +32,7 @@ import { LoggerService } from '../../services/logger/logger.service'; import { OpenViduService } from '../../services/openvidu/openvidu.service'; import { ParticipantService } from '../../services/participant/participant.service'; import { StorageService } from '../../services/storage/storage.service'; +import { TokenService } from '../../services/token/token.service'; @Component({ selector: 'ov-videoconference', @@ -84,10 +85,9 @@ export class VideoconferenceComponent implements OnInit, OnDestroy, AfterViewIni this.log.w('No tokens received'); } else { if (tokens.webcam || tokens.screen) { - this._tokens = { - webcam: tokens.webcam, - screen: tokens.screen - }; + this.tokenService.setWebcamToken(tokens.webcam); + this.tokenService.setScreenToken(tokens.screen); + this.canPublish = true; } } } @@ -116,7 +116,7 @@ export class VideoconferenceComponent implements OnInit, OnDestroy, AfterViewIni joinSessionClicked: boolean = false; participantReady: boolean = false; - _tokens: { webcam: string; screen: string }; + canPublish: boolean = false; error: boolean = false; errorMessage: string = ''; showPrejoin: boolean = true; @@ -130,7 +130,8 @@ export class VideoconferenceComponent implements OnInit, OnDestroy, AfterViewIni private deviceSrv: DeviceService, private openviduService: OpenViduService, private actionService: ActionService, - private libService: OpenViduAngularConfigService + private libService: OpenViduAngularConfigService, + private tokenService: TokenService, ) { this.log = this.loggerSrv.get('VideoconferenceComponent'); } diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/token/token.service.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/token/token.service.ts index 4f7bd811..1f13858c 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/token/token.service.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/token/token.service.ts @@ -1,6 +1,4 @@ import { Injectable } from '@angular/core'; -import { ILogger } from '../../models/logger.model'; -import { LoggerService } from '../logger/logger.service'; @Injectable({ providedIn: 'root' @@ -8,19 +6,14 @@ import { LoggerService } from '../logger/logger.service'; export class TokenService { private webcamToken = ''; private screenToken = ''; - private sessionId = ''; - private log: ILogger; - constructor(private loggerSrv: LoggerService) { - this.log = this.loggerSrv.get('TokenService'); - } + constructor() {} - - setWebcamToken(token: string){ + setWebcamToken(token: string) { this.webcamToken = token; } - setScreenToken(token: string){ + setScreenToken(token: string) { this.screenToken = token; }