openvidu-testapp: reconnect on server failure

pull/660/head
pabloFuente 2021-10-19 18:03:58 +02:00
parent e785519b33
commit 5aed7fa9f0
4 changed files with 23 additions and 3 deletions

View File

@ -50,3 +50,7 @@ mat-radio-button:first-child {
mat-form-field { mat-form-field {
margin-right: 9px; margin-right: 9px;
} }
#force-publishing-checkbox {
margin-right: 10px;
}

View File

@ -118,10 +118,13 @@
</mat-form-field> </mat-form-field>
</div> </div>
<div id="force-publishing-div"> <div>
<mat-checkbox class="checkbox-form" [(ngModel)]="forcePublishing" id="force-publishing-checkbox">Force <mat-checkbox class="checkbox-form" [(ngModel)]="forcePublishing" id="force-publishing-checkbox">Force
publishing publishing
</mat-checkbox> </mat-checkbox>
<mat-checkbox class="checkbox-form" [(ngModel)]="reconnectionOnServerFailure" id="reconnection-on-server-failure-checkbox">
Reconnection on server failure
</mat-checkbox>
</div> </div>
</div> </div>
@ -132,5 +135,5 @@
<mat-dialog-actions> <mat-dialog-actions>
<button id="cancel-btn" mat-button [mat-dialog-close]="undefined">CANCEL</button> <button id="cancel-btn" mat-button [mat-dialog-close]="undefined">CANCEL</button>
<button id="save-btn" mat-button <button id="save-btn" mat-button
[mat-dialog-close]="{sessionProperties: sessionProperties, turnConf: turnConf, manualTurnConf: manualTurnConf, customToken: customToken, forcePublishing: forcePublishing, connectionProperties: generateConnectionProperties()}">SAVE</button> [mat-dialog-close]="{sessionProperties: sessionProperties, turnConf: turnConf, manualTurnConf: manualTurnConf, customToken: customToken, forcePublishing: forcePublishing, reconnectionOnServerFailure: reconnectionOnServerFailure, connectionProperties: generateConnectionProperties()}">SAVE</button>
</mat-dialog-actions> </mat-dialog-actions>

View File

@ -15,6 +15,7 @@ export class SessionPropertiesDialogComponent {
manualTurnConf: RTCIceServer = { urls: [] }; manualTurnConf: RTCIceServer = { urls: [] };
customToken: string; customToken: string;
forcePublishing: boolean = false; forcePublishing: boolean = false;
reconnectionOnServerFailure: boolean = false;
connectionProperties: ConnectionProperties; connectionProperties: ConnectionProperties;
forceVideoCodec = VideoCodec; forceVideoCodec = VideoCodec;
@ -33,6 +34,7 @@ export class SessionPropertiesDialogComponent {
this.manualTurnConf = data.manualTurnConf; this.manualTurnConf = data.manualTurnConf;
this.customToken = data.customToken; this.customToken = data.customToken;
this.forcePublishing = data.forcePublishing; this.forcePublishing = data.forcePublishing;
this.reconnectionOnServerFailure = data.reconnectionOnServerFailure;
this.connectionProperties = data.connectionProperties; this.connectionProperties = data.connectionProperties;
} }

View File

@ -150,6 +150,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
manualTurnConf: RTCIceServer = { urls: [] }; manualTurnConf: RTCIceServer = { urls: [] };
customToken: string; customToken: string;
forcePublishing: boolean; forcePublishing: boolean;
reconnectionOnServerFailure: boolean;
connectionProperties: ConnectionProperties = { connectionProperties: ConnectionProperties = {
role: OpenViduRole.PUBLISHER, role: OpenViduRole.PUBLISHER,
record: true, record: true,
@ -448,12 +449,20 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
if (this.sessionEvents.sessionDisconnected !== oldValues.sessionDisconnected || firstTime) { if (this.sessionEvents.sessionDisconnected !== oldValues.sessionDisconnected || firstTime) {
this.session.off('sessionDisconnected'); this.session.off('sessionDisconnected');
if (this.sessionEvents.sessionDisconnected) { if (this.sessionEvents.sessionDisconnected) {
this.session.on('sessionDisconnected', (event: SessionDisconnectedEvent) => { this.session.on('sessionDisconnected', async (event: SessionDisconnectedEvent) => {
this.updateEventList('sessionDisconnected', '', event); this.updateEventList('sessionDisconnected', '', event);
this.subscribers = []; this.subscribers = [];
delete this.publisher; delete this.publisher;
delete this.session; delete this.session;
delete this.OV; delete this.OV;
if (event.reason === 'nodeCrashed' && this.reconnectionOnServerFailure) {
console.warn('Reconnecting after node crash');
await this.initializeNodeClient((event.target as Session).sessionId);
const connection: Connection = await this.createConnection();
this.joinSessionShared(connection.token);
}
}); });
} }
} }
@ -634,6 +643,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
manualTurnConf: this.manualTurnConf, manualTurnConf: this.manualTurnConf,
customToken: this.customToken, customToken: this.customToken,
forcePublishing: this.forcePublishing, forcePublishing: this.forcePublishing,
reconnectionOnServerFailure: this.reconnectionOnServerFailure,
connectionProperties: this.connectionProperties, connectionProperties: this.connectionProperties,
} }
}); });
@ -648,6 +658,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
this.manualTurnConf = result.manualTurnConf; this.manualTurnConf = result.manualTurnConf;
this.customToken = result.customToken; this.customToken = result.customToken;
this.forcePublishing = result.forcePublishing; this.forcePublishing = result.forcePublishing;
this.reconnectionOnServerFailure = result.reconnectionOnServerFailure;
this.connectionProperties = result.connectionProperties; this.connectionProperties = result.connectionProperties;
} }
document.getElementById('session-settings-btn-' + this.index).classList.remove('cdk-program-focused'); document.getElementById('session-settings-btn-' + this.index).classList.remove('cdk-program-focused');