This commit is contained in:
Mona Mayrhofer 2026-03-03 21:38:18 +01:00
parent 579869f2f0
commit 8664f9d210
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 374AB152BDEBA1AE
9 changed files with 302 additions and 9 deletions

View file

@ -13,7 +13,7 @@ pub fn Controls() -> Element {
#[css_module("/assets/styling/controls.module.css")]
struct Styles;
let mut socket = use_websocket(move || mouse_move(WebSocketOptions::new()));
let mut socket = use_websocket(move || remote_control(WebSocketOptions::new()));
use_future(move || async move {
loop {
@ -34,12 +34,44 @@ pub fn Controls() -> Element {
});
});
rsx! {
div {
class: Styles::controls,
MouseArea { onevent: event_handler }
KeyboardArea { onevent: event_handler }
}
match *socket.status().read() {
dioxus_fullstack::WebsocketState::Connecting => {
rsx! {
div {
"Connecting..."
}
}
},
dioxus_fullstack::WebsocketState::Open => {
rsx! {
div {
class: Styles::controls,
MouseArea { onevent: event_handler }
KeyboardArea { onevent: event_handler }
}
}
},
dioxus_fullstack::WebsocketState::Closing => {
rsx! {
div {
"Closing..."
}
}
},
dioxus_fullstack::WebsocketState::Closed => {
rsx! {
div {
"Closed..."
}
}
},
dioxus_fullstack::WebsocketState::FailedToConnect => {
rsx! {
div {
"Failed to connect..."
}
}
},
}
}
@ -60,8 +92,8 @@ enum ServerEvent {
}
#[expect(clippy::unused_async)]
#[get("/api/mouse_move_ws", mouse_service: State<crate::server::input_proxy_service::InputProxyService>)]
async fn mouse_move(
#[get("/api/remote_control_wss", mouse_service: State<crate::server::input_proxy_service::InputProxyService>)]
async fn remote_control(
options: WebSocketOptions
) -> Result<Websocket<ClientEvent, ServerEvent, CborEncoding>> {
Ok(options.on_upgrade(move |mut socket| async move {