Added port read

This commit is contained in:
Pax1601 2024-10-08 14:27:25 +02:00
parent 804743c051
commit ef48147322
2 changed files with 11 additions and 3 deletions

View File

@ -29,6 +29,7 @@ export class AudioManager {
#running: boolean = false;
#address: string = "localhost";
#port: number = 4000;
#endpoint: string = "audio";
#socket: WebSocket | null = null;
#guid: string = makeID(22);
#SRSClientUnitIDs: number[] = [];
@ -38,6 +39,9 @@ export class AudioManager {
let config = getApp().getConfig();
if (config["WSPort"]) {
this.setPort(config["WSPort"]);
}
if (config["WSAddress"]) {
this.setEndpoint(config["WSEndpoint"]);
}
});
@ -55,9 +59,9 @@ export class AudioManager {
let res = this.#address.match(/(?:http|https):\/\/(.+):/);
let wsAddress = res ? res[1] : this.#address;
if (this.#address.includes("https"))
this.#socket = new WebSocket(`wss://${wsAddress}/${getApp().getConfig()['WSAddress']}`);
this.#socket = new WebSocket(`wss://${wsAddress}/${this.#endpoint}`);
else
this.#socket = new WebSocket(`ws://${wsAddress}:${getApp().getConfig()['WSPort']}`);
this.#socket = new WebSocket(`ws://${wsAddress}:${this.#port}`);
/* Log the opening of the connection */
this.#socket.addEventListener("open", (event) => {
@ -136,6 +140,10 @@ export class AudioManager {
this.#port = port;
}
setEndpoint(endpoint) {
this.#endpoint = endpoint;
}
addFileSource(file) {
console.log(`Adding file source from ${file.name}`);
if (!this.#running) {

View File

@ -37,6 +37,6 @@
"audio": {
"SRSPort": 5002,
"WSPort": 4000,
"WSAddress": "audio"
"WSEndpoint": "audio"
}
}