aboutsummaryrefslogtreecommitdiff
path: root/src/routes/start.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/start.rs')
-rw-r--r--src/routes/start.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/routes/start.rs b/src/routes/start.rs
index 401ae97..1555db3 100644
--- a/src/routes/start.rs
+++ b/src/routes/start.rs
@@ -42,9 +42,20 @@ pub async fn start(State(state): State<Arc<crate::AppState>>, headers: HeaderMap
42 )?; 42 )?;
43 let dev_id = device.id.clone(); 43 let dev_id = device.id.clone();
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 mut uuid: Option<String> = None;
46 for (key, value) in state.ping_map.clone() {
47 if value.ip == device.ip {
48 debug!("service already exists");
49 uuid = Some(key);
50 break;
51 }
52 };
53 let uuid_gen = match uuid {
54 Some(u) => u,
55 None => Uuid::new_v4().to_string(),
56 };
46 let uuid_genc = uuid_gen.clone(); 57 let uuid_genc = uuid_gen.clone();
47 // TODO: Check if service already runs 58
48 tokio::spawn(async move { 59 tokio::spawn(async move {
49 debug!("init ping service"); 60 debug!("init ping service");
50 state.ping_map.insert(uuid_gen.clone(), PingValue { ip: device.ip.clone(), online: false }); 61 state.ping_map.insert(uuid_gen.clone(), PingValue { ip: device.ip.clone(), online: false });