openvidu-component: Refactored components

pull/707/head
csantosm 2022-02-04 11:26:27 +01:00
parent 055e370669
commit 76c51af4ef
2 changed files with 9 additions and 13 deletions

View File

@ -1,4 +1,4 @@
import { AfterViewInit, Component, ComponentRef, ContentChild, Directive, Input, OnDestroy, OnInit, TemplateRef, Type, ViewChild, ViewContainerRef } from '@angular/core'; import { AfterViewInit, Component, ContentChild, OnDestroy, OnInit, TemplateRef } from '@angular/core';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { ParticipantService } from '../../services/participant/participant.service'; import { ParticipantService } from '../../services/participant/participant.service';
import { ParticipantAbstractModel } from '../../models/participant.model'; import { ParticipantAbstractModel } from '../../models/participant.model';
@ -10,25 +10,16 @@ import { LayoutService } from '../../services/layout/layout.service';
styleUrls: ['./layout.component.css'] styleUrls: ['./layout.component.css']
}) })
export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit { export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit {
// @ContentChild('customLocalParticipant', { read: TemplateRef }) customLocalParticipantTemplate: TemplateRef<any>;
// @ContentChild('customRemoteParticipants', { read: TemplateRef }) customRemoteParticipantsTemplate: TemplateRef<any>;
@ContentChild('stream', { read: TemplateRef }) streamTemplate: TemplateRef<any>; @ContentChild('stream', { read: TemplateRef }) streamTemplate: TemplateRef<any>;
localParticipant: ParticipantAbstractModel; localParticipant: ParticipantAbstractModel;
remoteParticipants: ParticipantAbstractModel[] = []; remoteParticipants: ParticipantAbstractModel[] = [];
protected localParticipantSubs: Subscription; protected localParticipantSubs: Subscription;
protected remoteParticipantsSubs: Subscription; protected remoteParticipantsSubs: Subscription;
protected updateLayoutInterval: NodeJS.Timer;
constructor(protected layoutService: LayoutService, protected participantService: ParticipantService) {} constructor(protected layoutService: LayoutService, protected participantService: ParticipantService) {}
ngOnInit(): void { ngOnInit(): void {
this.layoutService.initialize();
this.subscribeToUsers(); this.subscribeToUsers();
} }

View File

@ -1,4 +1,4 @@
import { Component, ContentChild, EventEmitter, HostListener, Input, OnInit, Output, TemplateRef, ViewChild } from '@angular/core'; import { AfterViewInit, Component, ContentChild, EventEmitter, HostListener, Input, OnInit, Output, TemplateRef, ViewChild } from '@angular/core';
import { Subscriber, Session, StreamEvent, StreamPropertyChangedEvent, SessionDisconnectedEvent, ConnectionEvent } from 'openvidu-browser'; import { Subscriber, Session, StreamEvent, StreamPropertyChangedEvent, SessionDisconnectedEvent, ConnectionEvent } from 'openvidu-browser';
import { VideoType } from '../../models/video-type.model'; import { VideoType } from '../../models/video-type.model';
@ -23,7 +23,7 @@ import { SidenavMenuService } from '../../services/sidenav-menu/sidenav-menu.ser
templateUrl: './session.component.html', templateUrl: './session.component.html',
styleUrls: ['./session.component.css'] styleUrls: ['./session.component.css']
}) })
export class SessionComponent implements OnInit { export class SessionComponent implements OnInit, AfterViewInit {
@ContentChild('toolbar', { read: TemplateRef }) toolbarTemplate: TemplateRef<any>; @ContentChild('toolbar', { read: TemplateRef }) toolbarTemplate: TemplateRef<any>;
@ContentChild('layout', { read: TemplateRef }) layoutTemplate: TemplateRef<any>; @ContentChild('layout', { read: TemplateRef }) layoutTemplate: TemplateRef<any>;
@ContentChild('panel', { read: TemplateRef }) panelTemplate: TemplateRef<any>; @ContentChild('panel', { read: TemplateRef }) panelTemplate: TemplateRef<any>;
@ -84,7 +84,6 @@ export class SessionComponent implements OnInit {
} }
async ngOnInit() { async ngOnInit() {
// this.layoutService.initialize();
if (this.webrtcService.getWebcamSession() === null) { if (this.webrtcService.getWebcamSession() === null) {
this.webrtcService.initialize(); this.webrtcService.initialize();
@ -113,6 +112,12 @@ export class SessionComponent implements OnInit {
this._session.emit(this.session); this._session.emit(this.session);
} }
ngAfterViewInit(): void {
this.layoutService.initialize();
this.layoutService.update();
}
ngOnDestroy() { ngOnDestroy() {
// Reconnecting session is received in Firefox // Reconnecting session is received in Firefox
// To avoid 'Connection lost' message uses session.off() // To avoid 'Connection lost' message uses session.off()