pwa prep
This commit is contained in:
parent
579869f2f0
commit
8664f9d210
9 changed files with 302 additions and 9 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue