openvidu-library-angular: Access to core functions

This commit is contained in:
CSantos 2018-11-27 12:54:06 +01:00
parent a917f63007
commit 97b1ed6d39
2 changed files with 31 additions and 5 deletions

View File

@ -21,7 +21,7 @@
</div>
<div *ngIf="session" id="session">
<opv-session [sessionName]="mySessionId" [user]="myUserName" [token]="token" (leaveSession)="handlerLeaveSessionEvent($event)"
<opv-session #ovSessionComponent [sessionName]="mySessionId" [user]="myUserName" [token]="token" (leaveSession)="handlerLeaveSessionEvent($event)"
(joinSession)="handlerJoinSessionEvent($event)" (error)="handlerErrorEvent($event)">
</opv-session>
</div>

View File

@ -1,8 +1,8 @@
import { Component } from '@angular/core';
import { Component, ViewChild } from '@angular/core';
import { throwError as observableThrowError } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import {OpenviduSessionComponent, StreamEvent, Session, UserModel, OpenViduLayout, OpenViduLayoutOptions} from 'openvidu-angular';
@Component({
selector: 'app-root',
@ -19,7 +19,16 @@ export class AppComponent {
token: string;
session = false;
constructor(private httpClient: HttpClient) {}
ovSession: Session;
ovRemotesArray: UserModel[];
ovLocalUser: UserModel;
ovLayout: OpenViduLayout;
ovLayoutOptions: OpenViduLayoutOptions;
@ViewChild('ovSessionComponent')
public ovSessionComponent: OpenviduSessionComponent;
constructor(private httpClient: HttpClient) { }
joinSession() {
this.getToken().then((token) => {
@ -29,7 +38,7 @@ export class AppComponent {
}
handlerJoinSessionEvent(event): void {
// Do something
this.myMethod();
}
handlerLeaveSessionEvent(event): void {
@ -40,6 +49,23 @@ export class AppComponent {
// Do something
}
myMethod() {
this.ovSession = this.ovSessionComponent.getSession();
this.ovRemotesArray = this.ovSessionComponent.getRemotesArray();
this.ovLocalUser = this.ovSessionComponent.getLocalUser();
this.ovLayout = this.ovSessionComponent.getOpenviduLayout();
this.ovLayoutOptions = this.ovSessionComponent.getOpenviduLayputOptions();
this.ovSession.on('streamCreated', (event: StreamEvent) => {
// Do something
});
this.ovSession.on('streamDestroyed', (event: StreamEvent) => {
// Do something
});
}
/**
* --------------------------
* SERVER-SIDE RESPONSIBILITY