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