From b282e5d6769e3af96ccf27f2855b17f87fa9df63 Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Tue, 8 Oct 2024 14:29:59 +0200 Subject: [PATCH] Added handling of urls for audio manager address --- frontend/react/src/audio/audiomanager.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/frontend/react/src/audio/audiomanager.ts b/frontend/react/src/audio/audiomanager.ts index c0437796..6fea0503 100644 --- a/frontend/react/src/audio/audiomanager.ts +++ b/frontend/react/src/audio/audiomanager.ts @@ -39,7 +39,7 @@ export class AudioManager { let config = getApp().getConfig(); if (config["WSPort"]) { this.setPort(config["WSPort"]); - } + } if (config["WSAddress"]) { this.setEndpoint(config["WSEndpoint"]); } @@ -57,11 +57,11 @@ export class AudioManager { /* Connect the audio websocket */ let res = this.#address.match(/(?:http|https):\/\/(.+):/); + if (res === null) res = this.#address.match(/(?:http|https):\/\/(.+)/); + let wsAddress = res ? res[1] : this.#address; - if (this.#address.includes("https")) - this.#socket = new WebSocket(`wss://${wsAddress}/${this.#endpoint}`); - else - this.#socket = new WebSocket(`ws://${wsAddress}:${this.#port}`); + if (this.#address.includes("https")) this.#socket = new WebSocket(`wss://${wsAddress}/${this.#endpoint}`); + else this.#socket = new WebSocket(`ws://${wsAddress}:${this.#port}`); /* Log the opening of the connection */ this.#socket.addEventListener("open", (event) => { @@ -111,7 +111,6 @@ export class AudioManager { /* Add two default radios */ this.addRadio(); this.addRadio(); - }); document.dispatchEvent(new CustomEvent("audioManagerStateChanged")); }