diff options
author | FxQnLr <[email protected]> | 2023-10-29 19:55:26 +0100 |
---|---|---|
committer | FxQnLr <[email protected]> | 2023-10-29 19:55:26 +0100 |
commit | 0cca10290d089aabac8f2e4356cfaf80f06ae194 (patch) | |
tree | 708d44f2c439bb23b664114e16d92af63c693f3b /src/routes | |
parent | 00dd8a9abee6b9f0cfc37c6f20f30f0d99dfe91a (diff) | |
download | webol-0cca10290d089aabac8f2e4356cfaf80f06ae194.tar webol-0cca10290d089aabac8f2e4356cfaf80f06ae194.tar.gz webol-0cca10290d089aabac8f2e4356cfaf80f06ae194.zip |
does what is expected, but badly
Diffstat (limited to 'src/routes')
-rw-r--r-- | src/routes/start.rs | 5 | ||||
-rw-r--r-- | src/routes/status.rs | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/routes/start.rs b/src/routes/start.rs index 45e7ec8..b1c8a73 100644 --- a/src/routes/start.rs +++ b/src/routes/start.rs | |||
@@ -44,15 +44,16 @@ pub async fn start(State(state): State<Arc<crate::AppState>>, headers: HeaderMap | |||
44 | let uuid = if payload.ping.is_some_and(|ping| ping) { | 44 | let uuid = if payload.ping.is_some_and(|ping| ping) { |
45 | let uuid_gen = Uuid::new_v4().to_string(); | 45 | let uuid_gen = Uuid::new_v4().to_string(); |
46 | let uuid_genc = uuid_gen.clone(); | 46 | let uuid_genc = uuid_gen.clone(); |
47 | let uuid_gencc = uuid_gen.clone(); | ||
47 | tokio::spawn(async move{ | 48 | tokio::spawn(async move{ |
48 | debug!("Init ping service"); | 49 | debug!("Init ping service"); |
49 | state.ping_map.lock().await.insert(uuid_gen, ("192.168.178.94".to_string(), false)); | 50 | state.ping_map.lock().await.insert(uuid_gen, ("192.168.178.94".to_string(), false)); |
50 | 51 | ||
51 | warn!("{:?}", state.ping_map); | 52 | warn!("{:?}", state.ping_map); |
52 | 53 | ||
53 | crate::services::ping::spawn(state.ping_send.clone(), "192.168.178.94".to_string()).await; | 54 | crate::services::ping::spawn(state.ping_send.clone(), "192.168.178.94".to_string(), uuid_genc.clone(), state.ping_map.clone()).await |
54 | }); | 55 | }); |
55 | Some(uuid_genc) | 56 | Some(uuid_gencc) |
56 | } else { None }; | 57 | } else { None }; |
57 | Ok(Json(json!(StartResponse { id: device.id, boot: true, uuid }))) | 58 | Ok(Json(json!(StartResponse { id: device.id, boot: true, uuid }))) |
58 | } else { | 59 | } else { |
diff --git a/src/routes/status.rs b/src/routes/status.rs index cdecf6a..4a5ec67 100644 --- a/src/routes/status.rs +++ b/src/routes/status.rs | |||
@@ -1,12 +1,10 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | use axum::extract::{State, WebSocketUpgrade}; | 2 | use axum::extract::{State, WebSocketUpgrade}; |
3 | use axum::response::Response; | 3 | use axum::response::Response; |
4 | use serde::Deserialize; | ||
5 | use crate::AppState; | 4 | use crate::AppState; |
6 | use crate::services::ping::status_websocket; | 5 | use crate::services::ping::status_websocket; |
7 | 6 | ||
8 | #[axum_macros::debug_handler] | 7 | #[axum_macros::debug_handler] |
9 | pub async fn status(State(state): State<Arc<AppState>>, ws: WebSocketUpgrade) -> Response { | 8 | pub async fn status(State(state): State<Arc<AppState>>, ws: WebSocketUpgrade) -> Response { |
10 | // TODO: remove unwrap | ||
11 | ws.on_upgrade(move |socket| status_websocket(socket, state.ping_send.clone(), state.ping_map.clone())) | 9 | ws.on_upgrade(move |socket| status_websocket(socket, state.ping_send.clone(), state.ping_map.clone())) |
12 | } \ No newline at end of file | 10 | } \ No newline at end of file |