2022-01-28 15:16:09 +01:00
|
|
|
import {
|
2022-10-24 17:08:32 +02:00
|
|
|
ChangeDetectionStrategy,
|
|
|
|
ChangeDetectorRef,
|
|
|
|
Component,
|
2022-01-28 15:16:09 +01:00
|
|
|
ContentChild,
|
2022-04-25 16:17:32 +02:00
|
|
|
ElementRef,
|
2022-01-28 15:16:09 +01:00
|
|
|
EventEmitter,
|
|
|
|
HostListener,
|
2022-04-25 16:17:32 +02:00
|
|
|
Input,
|
2022-01-28 15:16:09 +01:00
|
|
|
OnInit,
|
|
|
|
Output,
|
|
|
|
TemplateRef,
|
2022-03-10 16:17:27 +01:00
|
|
|
ViewChild
|
2022-01-28 15:16:09 +01:00
|
|
|
} from '@angular/core';
|
2022-05-13 17:11:04 +02:00
|
|
|
import {
|
|
|
|
ConnectionEvent,
|
2022-10-24 17:08:32 +02:00
|
|
|
RecordingEvent,
|
|
|
|
Session,
|
|
|
|
SessionDisconnectedEvent,
|
|
|
|
StreamEvent,
|
|
|
|
StreamPropertyChangedEvent,
|
|
|
|
Subscriber
|
2022-05-13 17:11:04 +02:00
|
|
|
} from 'openvidu-browser';
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
import { ILogger } from '../../models/logger.model';
|
2022-10-14 14:46:32 +02:00
|
|
|
import { VideoType } from '../../models/video-type.model';
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-10-14 14:46:32 +02:00
|
|
|
import { animate, style, transition, trigger } from '@angular/animations';
|
2022-06-16 14:01:07 +02:00
|
|
|
import { MatDrawerContainer, MatSidenav } from '@angular/material/sidenav';
|
2022-10-14 14:46:32 +02:00
|
|
|
import { skip, Subscription } from 'rxjs';
|
2022-01-26 16:01:12 +01:00
|
|
|
import { SidenavMode } from '../../models/layout.model';
|
2022-04-06 12:00:42 +02:00
|
|
|
import { PanelType } from '../../models/panel.model';
|
2022-10-14 14:46:32 +02:00
|
|
|
import { Signal } from '../../models/signal.model';
|
|
|
|
import { ActionService } from '../../services/action/action.service';
|
2022-10-24 17:08:32 +02:00
|
|
|
import { CaptionService } from '../../services/caption/caption.service';
|
2022-10-14 14:46:32 +02:00
|
|
|
import { ChatService } from '../../services/chat/chat.service';
|
|
|
|
import { OpenViduAngularConfigService } from '../../services/config/openvidu-angular.config.service';
|
|
|
|
import { LayoutService } from '../../services/layout/layout.service';
|
|
|
|
import { LoggerService } from '../../services/logger/logger.service';
|
|
|
|
import { OpenViduService } from '../../services/openvidu/openvidu.service';
|
2022-06-16 14:01:07 +02:00
|
|
|
import { PanelEvent, PanelService } from '../../services/panel/panel.service';
|
2022-10-14 14:46:32 +02:00
|
|
|
import { ParticipantService } from '../../services/participant/participant.service';
|
|
|
|
import { PlatformService } from '../../services/platform/platform.service';
|
2022-04-25 16:17:32 +02:00
|
|
|
import { RecordingService } from '../../services/recording/recording.service';
|
2022-10-14 14:46:32 +02:00
|
|
|
import { TokenService } from '../../services/token/token.service';
|
2022-05-13 17:11:04 +02:00
|
|
|
import { TranslateService } from '../../services/translate/translate.service';
|
2022-03-23 13:48:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
@Component({
|
2022-01-26 11:30:30 +01:00
|
|
|
selector: 'ov-session',
|
|
|
|
templateUrl: './session.component.html',
|
2022-02-24 10:20:32 +01:00
|
|
|
styleUrls: ['./session.component.css'],
|
2022-10-24 17:08:32 +02:00
|
|
|
animations: [trigger('sessionAnimation', [transition(':enter', [style({ opacity: 0 }), animate('400ms', style({ opacity: 1 }))])])],
|
2022-02-24 10:20:32 +01:00
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
2022-01-19 17:24:11 +01:00
|
|
|
})
|
2022-01-26 11:30:30 +01:00
|
|
|
export class SessionComponent implements OnInit {
|
2022-02-17 17:26:30 +01:00
|
|
|
@ContentChild('toolbar', { read: TemplateRef }) toolbarTemplate: TemplateRef<any>;
|
|
|
|
@ContentChild('panel', { read: TemplateRef }) panelTemplate: TemplateRef<any>;
|
2022-02-03 17:08:23 +01:00
|
|
|
@ContentChild('layout', { read: TemplateRef }) layoutTemplate: TemplateRef<any>;
|
2022-01-26 16:01:12 +01:00
|
|
|
|
2022-04-25 16:17:32 +02:00
|
|
|
@Input() usedInPrejoinPage = false;
|
2022-03-10 17:08:12 +01:00
|
|
|
@Output() onSessionCreated = new EventEmitter<any>();
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
session: Session;
|
|
|
|
sessionScreen: Session;
|
2022-01-26 16:01:12 +01:00
|
|
|
|
|
|
|
sideMenu: MatSidenav;
|
|
|
|
|
|
|
|
sidenavMode: SidenavMode = SidenavMode.SIDE;
|
2022-06-16 14:01:07 +02:00
|
|
|
settingsPanelOpened: boolean;
|
|
|
|
drawer: MatDrawerContainer;
|
2022-10-14 14:46:32 +02:00
|
|
|
preparing: boolean = true;
|
2022-06-16 14:01:07 +02:00
|
|
|
|
2022-01-26 16:01:12 +01:00
|
|
|
protected readonly SIDENAV_WIDTH_LIMIT_MODE = 790;
|
|
|
|
|
|
|
|
protected menuSubscription: Subscription;
|
|
|
|
protected layoutWidthSubscription: Subscription;
|
|
|
|
|
|
|
|
protected updateLayoutInterval: NodeJS.Timer;
|
2022-10-24 17:08:32 +02:00
|
|
|
private captionLanguageSubscription: Subscription;
|
2022-01-26 16:01:12 +01:00
|
|
|
|
2022-01-19 17:24:11 +01:00
|
|
|
protected log: ILogger;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
protected actionService: ActionService,
|
2022-02-15 15:52:59 +01:00
|
|
|
protected openviduService: OpenViduService,
|
2022-01-19 17:24:11 +01:00
|
|
|
protected participantService: ParticipantService,
|
|
|
|
protected loggerSrv: LoggerService,
|
|
|
|
protected chatService: ChatService,
|
|
|
|
protected tokenService: TokenService,
|
2022-06-02 18:00:14 +02:00
|
|
|
private libService: OpenViduAngularConfigService,
|
2022-01-26 16:01:12 +01:00
|
|
|
protected layoutService: LayoutService,
|
2022-04-25 16:17:32 +02:00
|
|
|
protected panelService: PanelService,
|
2022-05-13 17:11:04 +02:00
|
|
|
private recordingService: RecordingService,
|
2022-06-09 12:27:54 +02:00
|
|
|
private translateService: TranslateService,
|
2022-10-24 17:08:32 +02:00
|
|
|
private captionService: CaptionService,
|
2022-10-14 14:46:32 +02:00
|
|
|
private platformService: PlatformService,
|
|
|
|
private cd: ChangeDetectorRef
|
2022-01-19 17:24:11 +01:00
|
|
|
) {
|
2022-01-26 11:30:30 +01:00
|
|
|
this.log = this.loggerSrv.get('SessionComponent');
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@HostListener('window:beforeunload')
|
|
|
|
beforeunloadHandler() {
|
|
|
|
this.leaveSession();
|
|
|
|
}
|
|
|
|
|
2022-01-26 16:01:12 +01:00
|
|
|
@HostListener('window:resize')
|
|
|
|
sizeChange() {
|
|
|
|
this.layoutService.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
@ViewChild('sidenav')
|
|
|
|
set sidenavMenu(menu: MatSidenav) {
|
|
|
|
setTimeout(() => {
|
|
|
|
if (menu) {
|
|
|
|
this.sideMenu = menu;
|
|
|
|
this.subscribeToTogglingMenu();
|
|
|
|
}
|
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
|
2022-05-13 17:11:04 +02:00
|
|
|
@ViewChild('videoContainer', { static: false, read: ElementRef })
|
2022-04-25 16:17:32 +02:00
|
|
|
set videoContainer(container: ElementRef) {
|
|
|
|
setTimeout(() => {
|
|
|
|
if (container && !this.toolbarTemplate) {
|
|
|
|
container.nativeElement.style.height = '100%';
|
|
|
|
container.nativeElement.style.minHeight = '100%';
|
|
|
|
this.layoutService.update();
|
|
|
|
}
|
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
|
2022-06-16 14:01:07 +02:00
|
|
|
@ViewChild('container')
|
|
|
|
set container(container: MatDrawerContainer) {
|
|
|
|
setTimeout(() => {
|
|
|
|
if (container) {
|
|
|
|
this.drawer = container;
|
|
|
|
this.drawer._contentMarginChanges.subscribe(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.stopUpdateLayoutInterval();
|
|
|
|
this.layoutService.update();
|
|
|
|
this.drawer.autosize = false;
|
|
|
|
}, 250);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
|
2022-01-19 17:24:11 +01:00
|
|
|
async ngOnInit() {
|
2022-05-13 17:11:04 +02:00
|
|
|
if (!this.usedInPrejoinPage) {
|
2022-06-16 14:01:07 +02:00
|
|
|
if (!this.tokenService.getScreenToken()) {
|
2022-06-02 18:00:14 +02:00
|
|
|
// Hide screenshare button if screen token does not exist
|
|
|
|
this.libService.screenshareButton.next(false);
|
|
|
|
}
|
2022-04-25 16:17:32 +02:00
|
|
|
this.session = this.openviduService.getWebcamSession();
|
|
|
|
this.sessionScreen = this.openviduService.getScreenSession();
|
2022-10-24 17:08:32 +02:00
|
|
|
this.subscribeToCaptionLanguage();
|
2022-04-25 16:17:32 +02:00
|
|
|
this.subscribeToConnectionCreatedAndDestroyed();
|
|
|
|
this.subscribeToStreamCreated();
|
|
|
|
this.subscribeToStreamDestroyed();
|
|
|
|
this.subscribeToStreamPropertyChange();
|
|
|
|
this.subscribeToNicknameChanged();
|
|
|
|
this.chatService.subscribeToChat();
|
|
|
|
this.subscribeToReconnection();
|
2022-06-22 14:01:50 +02:00
|
|
|
const recordingEnabled = this.libService.recordingButton.getValue() && this.libService.recordingActivity.getValue();
|
|
|
|
if (recordingEnabled) {
|
|
|
|
this.subscribeToRecordingEvents();
|
|
|
|
}
|
2022-04-25 16:17:32 +02:00
|
|
|
this.onSessionCreated.emit(this.session);
|
|
|
|
|
|
|
|
await this.connectToSession();
|
2022-06-09 12:27:54 +02:00
|
|
|
// ios devices appear with blank video. Muting and unmuting it fix this problem
|
|
|
|
if (this.platformService.isIos() && this.participantService.isMyCameraActive()) {
|
|
|
|
await this.openviduService.publishVideo(false);
|
|
|
|
await this.openviduService.publishVideo(true);
|
|
|
|
}
|
2022-04-25 16:17:32 +02:00
|
|
|
}
|
2022-10-14 14:46:32 +02:00
|
|
|
this.preparing = false;
|
|
|
|
this.cd.markForCheck();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
// Reconnecting session is received in Firefox
|
|
|
|
// To avoid 'Connection lost' message uses session.off()
|
|
|
|
this.session?.off('reconnecting');
|
|
|
|
this.participantService.clear();
|
|
|
|
this.session = null;
|
|
|
|
this.sessionScreen = null;
|
2022-01-26 16:01:12 +01:00
|
|
|
if (this.menuSubscription) this.menuSubscription.unsubscribe();
|
|
|
|
if (this.layoutWidthSubscription) this.layoutWidthSubscription.unsubscribe();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
leaveSession() {
|
|
|
|
this.log.d('Leaving session...');
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.disconnect();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-01-26 16:01:12 +01:00
|
|
|
protected subscribeToTogglingMenu() {
|
|
|
|
this.sideMenu.openedChange.subscribe(() => {
|
2022-06-16 14:01:07 +02:00
|
|
|
this.stopUpdateLayoutInterval();
|
2022-01-26 16:01:12 +01:00
|
|
|
this.layoutService.update();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.sideMenu.openedStart.subscribe(() => {
|
2022-06-16 14:01:07 +02:00
|
|
|
this.startUpdateLayoutInterval();
|
2022-01-26 16:01:12 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
this.sideMenu.closedStart.subscribe(() => {
|
2022-06-16 14:01:07 +02:00
|
|
|
this.startUpdateLayoutInterval();
|
2022-01-26 16:01:12 +01:00
|
|
|
});
|
|
|
|
|
2022-06-16 14:01:07 +02:00
|
|
|
this.menuSubscription = this.panelService.panelOpenedObs.pipe(skip(1)).subscribe((ev: PanelEvent) => {
|
|
|
|
if (this.sideMenu) {
|
|
|
|
this.settingsPanelOpened = ev.opened && ev.type === PanelType.SETTINGS;
|
|
|
|
|
|
|
|
if (this.sideMenu.opened && ev.opened) {
|
|
|
|
if (ev.type === PanelType.SETTINGS || ev.oldType === PanelType.SETTINGS) {
|
|
|
|
// Switch from SETTINGS to another panel and vice versa.
|
|
|
|
// As the SETTINGS panel will be bigger than others, the sidenav container must be updated.
|
|
|
|
// Setting autosize to 'true' allows update it.
|
|
|
|
this.drawer.autosize = true;
|
|
|
|
this.startUpdateLayoutInterval();
|
|
|
|
}
|
2022-06-02 10:57:47 +02:00
|
|
|
}
|
2022-06-16 14:01:07 +02:00
|
|
|
ev.opened ? this.sideMenu.open() : this.sideMenu.close();
|
|
|
|
}
|
|
|
|
});
|
2022-01-26 16:01:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected subscribeToLayoutWidth() {
|
|
|
|
this.layoutWidthSubscription = this.layoutService.layoutWidthObs.subscribe((width) => {
|
|
|
|
this.sidenavMode = width <= this.SIDENAV_WIDTH_LIMIT_MODE ? SidenavMode.OVER : SidenavMode.SIDE;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-19 17:24:11 +01:00
|
|
|
private async connectToSession(): Promise<void> {
|
|
|
|
try {
|
2022-02-25 11:19:21 +01:00
|
|
|
if (this.participantService.haveICameraAndScreenActive()) {
|
2022-02-15 15:52:59 +01:00
|
|
|
await this.openviduService.connectSession(this.openviduService.getWebcamSession(), this.tokenService.getWebcamToken());
|
|
|
|
await this.openviduService.connectSession(this.openviduService.getScreenSession(), this.tokenService.getScreenToken());
|
|
|
|
await this.openviduService.publish(this.participantService.getMyCameraPublisher());
|
|
|
|
await this.openviduService.publish(this.participantService.getMyScreenPublisher());
|
2022-02-25 11:19:21 +01:00
|
|
|
} else if (this.participantService.isOnlyMyScreenActive()) {
|
2022-02-15 15:52:59 +01:00
|
|
|
await this.openviduService.connectSession(this.openviduService.getScreenSession(), this.tokenService.getScreenToken());
|
|
|
|
await this.openviduService.publish(this.participantService.getMyScreenPublisher());
|
2022-01-19 17:24:11 +01:00
|
|
|
} else {
|
2022-02-15 15:52:59 +01:00
|
|
|
await this.openviduService.connectSession(this.openviduService.getWebcamSession(), this.tokenService.getWebcamToken());
|
|
|
|
await this.openviduService.publish(this.participantService.getMyCameraPublisher());
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
} catch (error) {
|
2022-01-28 15:16:09 +01:00
|
|
|
// this._error.emit({ error: error.error, messgae: error.message, code: error.code, status: error.status });
|
2022-01-19 17:24:11 +01:00
|
|
|
this.log.e('There was an error connecting to the session:', error.code, error.message);
|
2022-05-13 17:11:04 +02:00
|
|
|
this.actionService.openDialog(this.translateService.translate('ERRORS.SESSION'), error?.error || error?.message || error);
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private subscribeToConnectionCreatedAndDestroyed() {
|
|
|
|
this.session.on('connectionCreated', (event: ConnectionEvent) => {
|
|
|
|
const connectionId = event.connection?.connectionId;
|
|
|
|
const nickname: string = this.participantService.getNicknameFromConnectionData(event.connection.data);
|
2022-02-15 15:52:59 +01:00
|
|
|
const isRemoteConnection: boolean = !this.openviduService.isMyOwnConnection(connectionId);
|
2022-01-19 17:24:11 +01:00
|
|
|
const isCameraConnection: boolean = !nickname?.includes(`_${VideoType.SCREEN}`);
|
|
|
|
const data = event.connection?.data;
|
|
|
|
|
|
|
|
if (isRemoteConnection && isCameraConnection) {
|
|
|
|
// Adding participant when connection is created and it's not screen
|
|
|
|
this.participantService.addRemoteConnection(connectionId, data, null);
|
|
|
|
|
|
|
|
//Sending nicnkanme signal to new participants
|
2022-02-15 15:52:59 +01:00
|
|
|
if (this.openviduService.needSendNicknameSignal()) {
|
2022-02-28 13:48:58 +01:00
|
|
|
const data = { clientData: this.participantService.getMyNickname() };
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.sendSignal(Signal.NICKNAME_CHANGED, [event.connection], data);
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.session.on('connectionDestroyed', (event: ConnectionEvent) => {
|
|
|
|
const nickname: string = this.participantService.getNicknameFromConnectionData(event.connection.data);
|
2022-02-15 15:52:59 +01:00
|
|
|
const isRemoteConnection: boolean = !this.openviduService.isMyOwnConnection(event.connection.connectionId);
|
2022-01-19 17:24:11 +01:00
|
|
|
const isCameraConnection: boolean = !nickname?.includes(`_${VideoType.SCREEN}`);
|
|
|
|
// Deleting participant when connection is destroyed
|
|
|
|
if (isRemoteConnection && isCameraConnection) {
|
|
|
|
this.participantService.removeConnectionByConnectionId(event.connection.connectionId);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private subscribeToStreamCreated() {
|
2022-10-24 17:08:32 +02:00
|
|
|
this.session.on('streamCreated', async (event: StreamEvent) => {
|
2022-01-19 17:24:11 +01:00
|
|
|
const connectionId = event.stream?.connection?.connectionId;
|
|
|
|
const data = event.stream?.connection?.data;
|
|
|
|
|
2022-02-15 15:52:59 +01:00
|
|
|
const isRemoteConnection: boolean = !this.openviduService.isMyOwnConnection(connectionId);
|
2022-01-19 17:24:11 +01:00
|
|
|
if (isRemoteConnection) {
|
|
|
|
const subscriber: Subscriber = this.session.subscribe(event.stream, undefined);
|
|
|
|
this.participantService.addRemoteConnection(connectionId, data, subscriber);
|
|
|
|
// this.oVSessionService.sendNicknameSignal(event.stream.connection);
|
2022-10-31 13:40:39 +01:00
|
|
|
|
|
|
|
if (this.participantService.getTypeConnectionData(data) === VideoType.CAMERA) {
|
|
|
|
// Only subscribe to STT when stream is CAMERA type and it is a remote stream
|
|
|
|
try {
|
|
|
|
await this.session.subscribeToSpeechToText(event.stream, this.captionService.getLangSelected().ISO);
|
|
|
|
} catch (error) {
|
|
|
|
this.log.e('Error subscribing from STT: ', error);
|
|
|
|
}
|
2022-10-24 17:08:32 +02:00
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private subscribeToStreamDestroyed() {
|
2022-10-24 17:08:32 +02:00
|
|
|
this.session.on('streamDestroyed', async (event: StreamEvent) => {
|
2022-01-19 17:24:11 +01:00
|
|
|
const connectionId = event.stream.connection.connectionId;
|
|
|
|
this.participantService.removeConnectionByConnectionId(connectionId);
|
2022-10-24 17:08:32 +02:00
|
|
|
try {
|
|
|
|
await this.session.unsubscribeFromSpeechToText(event.stream);
|
|
|
|
} catch (error) {
|
|
|
|
this.log.e('Error unsubscribing from STT: ', error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private subscribeToCaptionLanguage() {
|
|
|
|
this.captionLanguageSubscription = this.captionService.captionLangObs.subscribe(async (lang) => {
|
|
|
|
// Unsubscribe all streams from speech to text and re-subscribe with new language
|
|
|
|
this.log.d('Re-subscribe from STT because of language changed to ', lang.ISO);
|
|
|
|
for (const participant of this.participantService.getRemoteParticipants()) {
|
2022-10-31 14:15:58 +01:00
|
|
|
const streamManager = participant.getCameraConnection()?.streamManager;
|
|
|
|
if (!!streamManager?.stream) {
|
|
|
|
try {
|
|
|
|
await this.session.unsubscribeFromSpeechToText(streamManager.stream);
|
|
|
|
await this.session.subscribeToSpeechToText(streamManager.stream, lang.ISO);
|
|
|
|
} catch (error) {
|
|
|
|
this.log.e('Error re-subscribing to STT: ', error);
|
|
|
|
}
|
2022-10-24 17:08:32 +02:00
|
|
|
}
|
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private subscribeToStreamPropertyChange() {
|
2022-02-25 13:53:49 +01:00
|
|
|
this.session.on('streamPropertyChanged', (event: StreamPropertyChangedEvent) => {
|
|
|
|
const connectionId = event.stream.connection.connectionId;
|
|
|
|
const isRemoteConnection: boolean = !this.openviduService.isMyOwnConnection(connectionId);
|
|
|
|
if (isRemoteConnection) {
|
|
|
|
this.participantService.updateRemoteParticipants();
|
|
|
|
}
|
|
|
|
});
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private subscribeToNicknameChanged() {
|
|
|
|
this.session.on(`signal:${Signal.NICKNAME_CHANGED}`, (event: any) => {
|
|
|
|
const connectionId = event.from.connectionId;
|
2022-02-15 15:52:59 +01:00
|
|
|
const isRemoteConnection: boolean = !this.openviduService.isMyOwnConnection(connectionId);
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
if (isRemoteConnection) {
|
|
|
|
const nickname = this.participantService.getNicknameFromConnectionData(event.data);
|
2022-02-28 14:37:35 +01:00
|
|
|
this.participantService.setRemoteNickname(connectionId, nickname);
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private subscribeToReconnection() {
|
|
|
|
this.session.on('reconnecting', () => {
|
|
|
|
this.log.w('Connection lost: Reconnecting');
|
2022-05-13 17:11:04 +02:00
|
|
|
this.actionService.openDialog(
|
2022-06-17 15:52:33 +02:00
|
|
|
this.translateService.translate('ERRORS.CONNECTION'),
|
|
|
|
this.translateService.translate('ERRORS.RECONNECT'),
|
2022-05-13 17:11:04 +02:00
|
|
|
false
|
|
|
|
);
|
2022-01-19 17:24:11 +01:00
|
|
|
});
|
|
|
|
this.session.on('reconnected', () => {
|
|
|
|
this.log.w('Connection lost: Reconnected');
|
|
|
|
this.actionService.closeDialog();
|
|
|
|
});
|
|
|
|
this.session.on('sessionDisconnected', (event: SessionDisconnectedEvent) => {
|
|
|
|
if (event.reason === 'networkDisconnect') {
|
|
|
|
this.actionService.closeDialog();
|
|
|
|
this.leaveSession();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-04-25 16:17:32 +02:00
|
|
|
|
|
|
|
private subscribeToRecordingEvents() {
|
|
|
|
this.session.on('recordingStarted', (event: RecordingEvent) => {
|
|
|
|
this.recordingService.startRecording(event);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.session.on('recordingStopped', (event: RecordingEvent) => {
|
|
|
|
this.recordingService.stopRecording(event);
|
|
|
|
});
|
|
|
|
}
|
2022-06-16 14:01:07 +02:00
|
|
|
|
|
|
|
private startUpdateLayoutInterval() {
|
|
|
|
this.updateLayoutInterval = setInterval(() => {
|
|
|
|
this.layoutService.update();
|
|
|
|
}, 50);
|
|
|
|
}
|
|
|
|
|
|
|
|
private stopUpdateLayoutInterval() {
|
|
|
|
if (this.updateLayoutInterval) {
|
|
|
|
clearInterval(this.updateLayoutInterval);
|
|
|
|
}
|
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|