Skip to content

Commit

Permalink
openvidu-testapp: updated to new createConnection API
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloFuente committed Oct 20, 2020
1 parent fb39355 commit 93c86d3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ <h2 mat-dialog-title>API REST</h2>
<input matInput id="stream-id-field" placeholder="streamId" [(ngModel)]="streamId">
</mat-form-field>
<div style="margin-left:9px">
<mat-checkbox class="checkbox-form" [(ngModel)]="tokenOptions.record" id="record-checkbox">Record
<mat-checkbox class="checkbox-form" [(ngModel)]="connectionOptions.record" id="record-checkbox">Record
</mat-checkbox>
<mat-form-field class="inner-text-input" [style.fontSize.px]=14>
<mat-select [(ngModel)]="tokenOptions.role" id="token-role-select">
<mat-select [(ngModel)]="connectionOptions.role" id="token-role-select">
<mat-option *ngFor="let enumerator of enumToArray(openviduRoles)" [value]="enumerator">
<span [attr.id]="'option-' + enumerator">{{ enumerator }}</span>
</mat-option>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';

import { OpenVidu as OpenViduAPI, Session as SessionAPI, Recording, RecordingProperties, RecordingLayout, TokenOptions, OpenViduRole } from 'openvidu-node-client';
import { OpenVidu as OpenViduAPI, Session as SessionAPI, Recording, RecordingProperties, RecordingLayout, ConnectionOptions, OpenViduRole } from 'openvidu-node-client';

@Component({
selector: 'app-session-api-dialog',
Expand All @@ -26,7 +26,7 @@ export class SessionApiDialogComponent {
recPropertiesIcon = 'add_circle';
showRecProperties = false;

tokenOptions: TokenOptions = {
connectionOptions: ConnectionOptions = {
record: true,
role: OpenViduRole.PUBLISHER
};
Expand Down Expand Up @@ -174,9 +174,9 @@ export class SessionApiDialogComponent {

updateConnection() {
console.log('Updating connection');
this.session.updateConnection(this.connectionId, this.tokenOptions)
this.session.updateConnection(this.connectionId, this.connectionOptions)
.then(modifiedConnection => {
this.response = 'Connection updated: ' + JSON.stringify({ role: modifiedConnection.role, record: modifiedConnection.record });
this.response = 'Connection updated: ' + JSON.stringify({ role: modifiedConnection.connectionOptions.role, record: modifiedConnection.connectionOptions.record });
})
.catch(error => {
this.response = 'Error [' + error.message + ']';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h2 mat-dialog-title>User configuration</h2>
<mat-dialog-content>
<label class="label">Role</label>
<div id="role-div">
<mat-radio-group name="Role" [(ngModel)]="tokenOptions.role">
<mat-radio-group name="Role" [(ngModel)]="connectionOptions.role">
<mat-radio-button id="radio-btn-sub" value="SUBSCRIBER">SUB</mat-radio-button>
<mat-radio-button id="radio-btn-pub" value="PUBLISHER">PUB</mat-radio-button>
<mat-radio-button id="radio-btn-mod" value="MODERATOR">MOD</mat-radio-button>
Expand All @@ -79,19 +79,19 @@ <h2 mat-dialog-title>User configuration</h2>
<div id="kurento-config-div">
<mat-form-field style="width: 39%; margin-right: 5px">
<input matInput placeholder="Max recv" type="number"
[(ngModel)]="tokenOptions.kurentoOptions.videoMaxRecvBandwidth">
[(ngModel)]="connectionOptions.kurentoOptions.videoMaxRecvBandwidth">
</mat-form-field>
<mat-form-field style="width: 39%">
<input matInput placeholder="Min recv" type="number"
[(ngModel)]="tokenOptions.kurentoOptions.videoMinRecvBandwidth">
[(ngModel)]="connectionOptions.kurentoOptions.videoMinRecvBandwidth">
</mat-form-field>
<mat-form-field style="width: 39%; margin-right: 5px">
<input matInput placeholder="Max send" type="number"
[(ngModel)]="tokenOptions.kurentoOptions.videoMaxSendBandwidth">
[(ngModel)]="connectionOptions.kurentoOptions.videoMaxSendBandwidth">
</mat-form-field>
<mat-form-field style="width: 39%">
<input matInput placeholder="Min send" type="number"
[(ngModel)]="tokenOptions.kurentoOptions.videoMinSendBandwidth">
[(ngModel)]="connectionOptions.kurentoOptions.videoMinSendBandwidth">
</mat-form-field>
<mat-chip-list *ngIf="filters.length > 0">
<mat-chip style="height: 20px" *ngFor="let filterName of filters"
Expand All @@ -108,7 +108,7 @@ <h2 mat-dialog-title>User configuration</h2>
</div>

<div id="record-div">
<mat-checkbox class="checkbox-form" [(ngModel)]="tokenOptions.record" id="record-checkbox">Record
<mat-checkbox class="checkbox-form" [(ngModel)]="connectionOptions.record" id="record-checkbox">Record
</mat-checkbox>
</div>

Expand All @@ -132,6 +132,6 @@ <h2 mat-dialog-title>User configuration</h2>
<mat-dialog-actions>
<button id="cancel-btn" mat-button [mat-dialog-close]="undefined">CANCEL</button>
<button id="save-btn" mat-button
[mat-dialog-close]="{sessionProperties: sessionProperties, turnConf: turnConf, manualTurnConf: manualTurnConf, customToken: customToken, forcePublishing: forcePublishing, tokenOptions: generateTokenOptions()}">SAVE</button>
[mat-dialog-close]="{sessionProperties: sessionProperties, turnConf: turnConf, manualTurnConf: manualTurnConf, customToken: customToken, forcePublishing: forcePublishing, connectionOptions: generateConnectionOptions()}">SAVE</button>
</mat-dialog-actions>
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';

import { SessionProperties, MediaMode, Recording, RecordingMode, RecordingLayout, TokenOptions } from 'openvidu-node-client';
import { SessionProperties, MediaMode, Recording, RecordingMode, RecordingLayout, ConnectionOptions } from 'openvidu-node-client';

@Component({
selector: 'app-session-properties-dialog',
Expand All @@ -15,7 +15,7 @@ export class SessionPropertiesDialogComponent {
manualTurnConf: RTCIceServer = { urls: [] };
customToken: string;
forcePublishing: boolean = false;
tokenOptions: TokenOptions;
connectionOptions: ConnectionOptions;

filterName = 'GStreamerFilter';
filters: string[] = [];
Expand All @@ -32,16 +32,16 @@ export class SessionPropertiesDialogComponent {
this.manualTurnConf = data.manualTurnConf;
this.customToken = data.customToken;
this.forcePublishing = data.forcePublishing;
this.tokenOptions = data.tokenOptions;
this.connectionOptions = data.connectionOptions;
}

enumToArray(enumerator: any) {
return Object.keys(enumerator);
}

generateTokenOptions(): TokenOptions {
this.tokenOptions.kurentoOptions.allowedFilters = this.filters;
return this.tokenOptions;
generateConnectionOptions(): ConnectionOptions {
this.connectionOptions.kurentoOptions.allowedFilters = this.filters;
return this.connectionOptions;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import {
MediaMode,
RecordingMode,
RecordingLayout,
TokenOptions,
Connection,
ConnectionOptions,
OpenViduRole,
RecordingProperties,
Recording,
Token
} from 'openvidu-node-client';
import { MatDialog, MAT_CHECKBOX_CLICK_ACTION } from '@angular/material';
import { ExtensionDialogComponent } from '../dialogs/extension-dialog/extension-dialog.component';
Expand Down Expand Up @@ -129,7 +129,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
manualTurnConf: RTCIceServer = { urls: [] };
customToken: string;
forcePublishing: boolean;
tokenOptions: TokenOptions = {
connectionOptions: ConnectionOptions = {
role: OpenViduRole.PUBLISHER,
record: true,
kurentoOptions: {
Expand Down Expand Up @@ -199,8 +199,8 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
if (!!this.customToken) {
this.joinSessionShared(this.customToken);
} else {
const token: Token = await this.getToken();
this.joinSessionShared(token.token);
const connection: Connection = await this.createConnection();
this.joinSessionShared(connection.token);
}
}

Expand Down Expand Up @@ -566,7 +566,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
manualTurnConf: this.manualTurnConf,
customToken: this.customToken,
forcePublishing: this.forcePublishing,
tokenOptions: this.tokenOptions,
connectionOptions: this.connectionOptions,
},
width: '450px'
});
Expand All @@ -581,7 +581,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
this.manualTurnConf = result.manualTurnConf;
this.customToken = result.customToken;
this.forcePublishing = result.forcePublishing;
this.tokenOptions = result.tokenOptions;
this.connectionOptions = result.connectionOptions;
}
document.getElementById('session-settings-btn-' + this.index).classList.remove('cdk-program-focused');
});
Expand Down Expand Up @@ -692,8 +692,8 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
this.sessionAPI = await this.OV_NodeClient.createSession(this.sessionProperties);
}

async getToken(): Promise<Token> {
return this.sessionAPI.createToken(this.tokenOptions);
async createConnection(): Promise<Connection> {
return this.sessionAPI.createConnection(this.connectionOptions);
}

updateEventFromChild(event: OpenViduEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class TestApirestComponent implements OnInit, OnDestroy {
getToken() {
const sessionId = this.data[this.selectedRadioIndex][0];

this.openviduRestService.getToken(this.openviduUrl, this.openviduSecret, sessionId, this.selectedRole, this.serverData)
this.openviduRestService.getToken(sessionId, this.selectedRole, this.serverData)
.then((token) => {
this.updateData();
})
Expand Down
2 changes: 1 addition & 1 deletion openvidu-testapp/src/app/services/openvidu-rest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class OpenviduRestService {
});
}

getToken(openviduURL: string, openviduSecret: string, sessionId: string, role: string, serverData: string): Promise<string> {
getToken(sessionId: string, role: string, serverData: string): Promise<string> {
const session: SessionAPI = this.sessionIdSession.get(sessionId);
const OVRole: OpenViduRoleAPI = OpenViduRoleAPI[role];

Expand Down

0 comments on commit 93c86d3

Please sign in to comment.