openvidu/openvidu-testapp/src/app/app.component.ts

58 lines
1.5 KiB
TypeScript
Raw Normal View History

2017-09-26 18:13:00 +02:00
import { Component } from '@angular/core';
import { Router } from '@angular/router';
2024-07-02 19:19:05 +02:00
import { LogLevel, setLogLevel } from 'livekit-client';
import { LivekitParamsService } from './services/livekit-params.service';
2017-09-26 18:13:00 +02:00
@Component({
2025-02-19 12:03:43 +01:00
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
standalone: false
2017-09-26 18:13:00 +02:00
})
export class AppComponent {
2024-07-02 19:19:05 +02:00
livekitUrl = 'ws://localhost:7880/'; // `${window.location.protocol === 'https:' ? 'wss' : 'ws'}://localhost:1880/`;
livekitApiKey = 'devkey';
livekitApiSecret = 'secret';
2017-09-26 18:13:00 +02:00
constructor(
private router: Router,
private livekitParamsService: LivekitParamsService
) {}
2024-07-02 19:19:05 +02:00
async ngOnInit() {
// LiveKit client logging. Change here to build with verbose logging.
// Levels: trace, debug, info (default), warn, error, silent.
setLogLevel(LogLevel.debug);
await this.updateParams();
console.log('LiveKit credentials updated');
}
updateUrl(url: any) {
this.livekitUrl = url;
this.updateParams();
}
2024-07-02 19:19:05 +02:00
updateApiKey(apiKey: any) {
this.livekitApiKey = apiKey;
this.updateParams();
}
2024-07-02 19:19:05 +02:00
updateApiSecret(apiSecret: any) {
this.livekitApiSecret = apiSecret;
this.updateParams();
}
async updateParams() {
let myUrl = this.livekitUrl;
if (!(myUrl.substring(myUrl.length - 1) === '/')) {
myUrl += '/';
}
await this.livekitParamsService.updateParams({
livekitUrl: myUrl,
livekitApiKey: this.livekitApiKey,
livekitApiSecret: this.livekitApiSecret,
});
2017-09-26 18:13:00 +02:00
}
}