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

50 lines
1.4 KiB
TypeScript
Raw Normal View History

2017-09-26 18:13:00 +02:00
import { Component } from '@angular/core';
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({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
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
2024-07-02 19:19:05 +02:00
constructor(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 += '/';
}
2024-07-02 19:19:05 +02:00
await this.livekitParamsService.updateParams({ livekitUrl: myUrl, livekitApiKey: this.livekitApiKey, livekitApiSecret: this.livekitApiSecret });
2017-09-26 18:13:00 +02:00
}
}