diff --git a/frontend/Cargo.lock b/frontend/Cargo.lock index 5279810..6837a35 100644 --- a/frontend/Cargo.lock +++ b/frontend/Cargo.lock @@ -1410,6 +1410,7 @@ dependencies = [ "env_logger", "ewebsock", "hrtime", + "js-sys", "log", "serde", "serde_json", diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml index d196880..a5513e0 100644 --- a/frontend/Cargo.toml +++ b/frontend/Cargo.toml @@ -10,6 +10,7 @@ eframe = { version = "0.27.0", default-features = false, features = [ "default_fonts", # Embed the default egui fonts. "glow", # Use the glow rendering backend. Alternative: "wgpu". ] } +js-sys = "0.3.69" log = "0.4" serde = { version = "1", features = ["derive"] } hrtime = "0.2.0" diff --git a/frontend/src/app.rs b/frontend/src/app.rs index f7ea3b1..3bdc5f0 100644 --- a/frontend/src/app.rs +++ b/frontend/src/app.rs @@ -7,6 +7,7 @@ use std::{ use egui::{Button, Color32, RichText, Rounding, Sense, Stroke, Vec2}; use ewebsock::{Options, WsReceiver, WsSender}; use wasm_timer::Instant; +use js_sys::eval; use crate::websocket::{ AddHyperdeckRequest, ClientRequest, HyperdeckConnectionState, HyperdeckRecordBay, @@ -27,8 +28,12 @@ pub struct HyperdeckMonitorApp { impl Default for HyperdeckMonitorApp { fn default() -> Self { + // returns voc.emf.camp:9681/ + let window_location = eval("window.location.host").unwrap().as_string().unwrap(); + // returns ws://voc.emf.camp:9681 + let api_websocket_location = format!("ws://{}ws", window_location); let (ws_sender, ws_receiver) = - ewebsock::connect("ws://127.0.0.1:9681/ws", Options::default()).unwrap(); + ewebsock::connect(api_websocket_location, Options::default()).unwrap(); Self { blink: false, last_blink_change: Instant::now(),