openvidu-components: Updated testapp

pull/780/head
Carlos Santos 2023-02-22 13:08:22 +01:00
parent 421869d48e
commit 8d4584dd79
3 changed files with 26 additions and 8 deletions

View File

@ -44,7 +44,7 @@
<div id="testing-app"> <div id="testing-app">
<h2>Testing APP</h2> <h2>Testing APP</h2>
<p>App for testing openvidu-angular</p> <p>App for automated testing of openvidu-angular</p>
<input type="hidden" #selection /> <input type="hidden" #selection />

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { RecordingInfo, TokenModel } from 'openvidu-angular'; import { BroadcastingService, BroadcastingStatus, RecordingInfo, RecordingService, RecordingStatus, TokenModel } from 'openvidu-angular';
import { RestService } from '../services/rest.service'; import { RestService } from '../services/rest.service';
@Component({ @Component({
@ -18,7 +18,11 @@ export class CallComponent implements OnInit {
recordingError: any; recordingError: any;
broadcastingError: any; broadcastingError: any;
constructor(private restService: RestService) {} constructor(
private restService: RestService,
private recordingService: RecordingService,
private broadcastingService: BroadcastingService
) {}
async ngOnInit() { async ngOnInit() {
await this.requestForTokens(); await this.requestForTokens();
@ -134,12 +138,15 @@ export class CallComponent implements OnInit {
} }
private async requestForTokens() { private async requestForTokens() {
const response = await this.restService.getTokensFromBackend(this.sessionId); const { broadcastingEnabled, recordingEnabled, recordings, cameraToken, screenToken, isRecordingActive, isBroadcastingActive } =
this.recordingList = response.recordings; await this.restService.getTokensFromBackend(this.sessionId);
this.recordingList = recordings;
this.tokens = { this.tokens = {
webcam: response.cameraToken, webcam: cameraToken,
screen: response.screenToken screen: screenToken
}; };
if (isRecordingActive) this.recordingService.updateStatus(RecordingStatus.STARTED);
if (isBroadcastingActive) this.broadcastingService.updateStatus(BroadcastingStatus.STARTED);
console.log('Token requested: ', this.tokens); console.log('Token requested: ', this.tokens);
} }

View File

@ -4,6 +4,17 @@ import { RecordingInfo } from 'openvidu-angular';
import { catchError, lastValueFrom } from 'rxjs'; import { catchError, lastValueFrom } from 'rxjs';
import { throwError as observableThrowError } from 'rxjs/internal/observable/throwError'; import { throwError as observableThrowError } from 'rxjs/internal/observable/throwError';
interface SessionResponse {
cameraToken: string;
screenToken: string;
recordingEnabled: boolean;
isRecordingActive: boolean;
recordings?: RecordingInfo[];
broadcastingEnabled: boolean;
isBroadcastingActive: boolean;
}
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
@ -19,7 +30,7 @@ export class RestService {
return await this.createToken(_sessionId, openviduServerUrl, openviduSecret); return await this.createToken(_sessionId, openviduServerUrl, openviduSecret);
} }
} }
async getTokensFromBackend(sessionId: string): Promise<{ cameraToken: string; screenToken: string; recordings?: RecordingInfo[] }> { async getTokensFromBackend(sessionId: string): Promise<SessionResponse> {
try { try {
return lastValueFrom(this.http.post<any>(this.baseHref + 'sessions', { sessionId })); return lastValueFrom(this.http.post<any>(this.baseHref + 'sessions', { sessionId }));
} catch (error) { } catch (error) {