mirror of https://github.com/OpenVidu/openvidu.git
openvidu-testapp: Session REST API extended to Session.close()
parent
79dcb26e6b
commit
954e5ff8f8
File diff suppressed because it is too large
Load Diff
|
@ -1,48 +1,48 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@angular/animations": "6.0.7",
|
||||
"@angular/cdk": "6.3.2",
|
||||
"@angular/common": "6.0.7",
|
||||
"@angular/compiler": "6.0.7",
|
||||
"@angular/core": "6.0.7",
|
||||
"@angular/flex-layout": "6.0.0-beta.16",
|
||||
"@angular/forms": "6.0.7",
|
||||
"@angular/http": "6.0.7",
|
||||
"@angular/material": "6.3.2",
|
||||
"@angular/platform-browser": "6.0.7",
|
||||
"@angular/platform-browser-dynamic": "6.0.7",
|
||||
"@angular/router": "6.0.7",
|
||||
"colormap": "2.3.0",
|
||||
"core-js": "2.5.7",
|
||||
"hammerjs": "2.0.8",
|
||||
"openvidu-browser": "2.3.0",
|
||||
"openvidu-node-client": "2.2.0",
|
||||
"rxjs": "6.2.1",
|
||||
"@angular/animations": "6.0.7",
|
||||
"@angular/cdk": "6.3.2",
|
||||
"@angular/common": "6.0.7",
|
||||
"@angular/compiler": "6.0.7",
|
||||
"@angular/core": "6.0.7",
|
||||
"@angular/flex-layout": "6.0.0-beta.16",
|
||||
"@angular/forms": "6.0.7",
|
||||
"@angular/http": "6.0.7",
|
||||
"@angular/material": "6.3.2",
|
||||
"@angular/platform-browser": "6.0.7",
|
||||
"@angular/platform-browser-dynamic": "6.0.7",
|
||||
"@angular/router": "6.0.7",
|
||||
"colormap": "2.3.0",
|
||||
"core-js": "2.5.7",
|
||||
"hammerjs": "2.0.8",
|
||||
"openvidu-browser": "2.3.0",
|
||||
"openvidu-node-client": "2.2.0",
|
||||
"rxjs": "6.2.1",
|
||||
"zone.js": "0.8.26"
|
||||
},
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "~0.6.8",
|
||||
"@angular/cli": "6.0.8",
|
||||
"@angular/compiler-cli": "6.0.7",
|
||||
"@angular/language-service": "6.0.7",
|
||||
"@types/jasmine": "2.8.8",
|
||||
"@types/jasminewd2": "2.0.3",
|
||||
"@types/node": "10.5.1",
|
||||
"codelyzer": "4.4.2",
|
||||
"ts-node": "7.0.0",
|
||||
"tslint": "5.10.0",
|
||||
"@angular-devkit/build-angular": "~0.6.8",
|
||||
"@angular/cli": "6.0.8",
|
||||
"@angular/compiler-cli": "6.0.7",
|
||||
"@angular/language-service": "6.0.7",
|
||||
"@types/jasmine": "2.8.8",
|
||||
"@types/jasminewd2": "2.0.3",
|
||||
"@types/node": "10.5.1",
|
||||
"codelyzer": "4.4.2",
|
||||
"ts-node": "7.0.0",
|
||||
"tslint": "5.10.0",
|
||||
"typescript": "2.7.2"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"name": "openvidu-testapp",
|
||||
"private": true,
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"name": "openvidu-testapp",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "ng build",
|
||||
"e2e": "ng e2e",
|
||||
"lint": "ng lint",
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"e2e": "ng e2e",
|
||||
"lint": "ng lint",
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"test": "ng test"
|
||||
},
|
||||
},
|
||||
"version": "2.3.0"
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import { Component, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
|
||||
|
||||
import { OpenVidu as OpenViduAPI } from 'openvidu-node-client';
|
||||
import { OpenVidu as OpenViduAPI, Session as SessionAPI } from 'openvidu-node-client';
|
||||
|
||||
@Component({
|
||||
selector: 'app-session-api-dialog',
|
||||
|
@ -9,6 +9,8 @@ import { OpenVidu as OpenViduAPI } from 'openvidu-node-client';
|
|||
<div>
|
||||
<h2 mat-dialog-title>API REST</h2>
|
||||
<mat-dialog-content>
|
||||
<button mat-button id="close-session-btn" (click)="closeSession()">Close session</button>
|
||||
<mat-divider></mat-divider>
|
||||
<button mat-button id="start-recording-btn" (click)="startRecording()">Start recording</button>
|
||||
<button mat-button id="list-recording-btn" (click)="listRecordings()">List recordings</button>
|
||||
<mat-divider></mat-divider>
|
||||
|
@ -23,7 +25,7 @@ import { OpenVidu as OpenViduAPI } from 'openvidu-node-client';
|
|||
</mat-form-field>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions>
|
||||
<button mat-button id="close-dialog-btn" [mat-dialog-close]="undefined">CLOSE</button>
|
||||
<button mat-button id="close-dialog-btn" [mat-dialog-close]="{session: session}">CLOSE</button>
|
||||
</mat-dialog-actions>
|
||||
</div>
|
||||
`,
|
||||
|
@ -36,6 +38,7 @@ import { OpenVidu as OpenViduAPI } from 'openvidu-node-client';
|
|||
export class SessionApiDialogComponent {
|
||||
|
||||
OV: OpenViduAPI;
|
||||
session: SessionAPI;
|
||||
sessionId: string;
|
||||
recordingId: string;
|
||||
response: string;
|
||||
|
@ -43,9 +46,26 @@ export class SessionApiDialogComponent {
|
|||
constructor(public dialogRef: MatDialogRef<SessionApiDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data) {
|
||||
this.OV = data.openVidu;
|
||||
this.session = data.session;
|
||||
this.sessionId = data.sessionId;
|
||||
}
|
||||
|
||||
closeSession() {
|
||||
console.log('Closing session');
|
||||
if (!this.session) {
|
||||
this.response = 'Error [Session undefined]';
|
||||
return;
|
||||
}
|
||||
this.session.close()
|
||||
.then(() => {
|
||||
this.response = 'Session closed';
|
||||
delete this.session;
|
||||
})
|
||||
.catch(error => {
|
||||
this.response = 'Error [' + error.message + ']';
|
||||
});
|
||||
}
|
||||
|
||||
startRecording() {
|
||||
console.log('Starting recording');
|
||||
this.OV.startRecording(this.sessionId)
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
} from 'openvidu-browser';
|
||||
import {
|
||||
OpenVidu as OpenViduAPI,
|
||||
Session as SessionAPI,
|
||||
SessionProperties as SessionPropertiesAPI,
|
||||
MediaMode,
|
||||
RecordingMode,
|
||||
|
@ -76,6 +77,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
subscribers: Subscriber[] = [];
|
||||
|
||||
// OpenVidu Node Client objects
|
||||
sessionAPI: SessionAPI;
|
||||
sessionProperties: SessionPropertiesAPI = {
|
||||
mediaMode: MediaMode.ROUTED,
|
||||
recordingMode: RecordingMode.MANUAL,
|
||||
|
@ -162,8 +164,6 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
this.clientData = 'TestClient';
|
||||
}
|
||||
|
||||
private removeHttps = input => input.replace(/^https?:\/\//, '');
|
||||
|
||||
joinSession(): void {
|
||||
|
||||
if (this.session) {
|
||||
|
@ -512,13 +512,17 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
const dialogRef = this.dialog.open(SessionApiDialogComponent, {
|
||||
data: {
|
||||
openVidu: new OpenViduAPI(this.openviduUrl, this.openviduSecret),
|
||||
session: this.sessionAPI,
|
||||
sessionId: !!this.session ? this.session.sessionId : this.sessionName
|
||||
},
|
||||
width: '280px',
|
||||
disableClose: true
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: string) => {
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if (!result.session) {
|
||||
delete this.sessionAPI;
|
||||
}
|
||||
document.getElementById('session-api-btn-' + this.index).classList.remove('cdk-program-focused');
|
||||
});
|
||||
}
|
||||
|
@ -595,6 +599,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
}
|
||||
return OV_NodeClient.createSession(this.sessionProperties)
|
||||
.then(session_NodeClient => {
|
||||
this.sessionAPI = session_NodeClient;
|
||||
return session_NodeClient.generateToken({ role: this.participantRole });
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@ import {
|
|||
StreamEvent,
|
||||
StreamManagerEvent,
|
||||
PublisherProperties,
|
||||
ConnectionEvent,
|
||||
StreamPropertyChangedEvent
|
||||
ConnectionEvent
|
||||
} from 'openvidu-browser';
|
||||
import {
|
||||
OpenVidu as OpenViduAPI,
|
||||
|
|
|
@ -2,11 +2,9 @@ import { Injectable } from '@angular/core';
|
|||
import {
|
||||
OpenVidu as OpenViduAPI,
|
||||
Session as SessionAPI,
|
||||
TokenOptions as TokenOptionsAPI,
|
||||
OpenViduRole as OpenViduRoleAPI,
|
||||
SessionProperties as SessionPropertiesAPI
|
||||
} from 'openvidu-node-client';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
@Injectable()
|
||||
export class OpenviduRestService {
|
||||
|
|
Loading…
Reference in New Issue