From 00dd8a9abee6b9f0cfc37c6f20f30f0d99dfe91a Mon Sep 17 00:00:00 2001
From: fx <felixquinn03@gmail.com>
Date: Wed, 25 Oct 2023 12:53:31 +0200
Subject: runs, no error handling

---
 src/main.rs | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'src/main.rs')

diff --git a/src/main.rs b/src/main.rs
index 124c44e..854b59d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,4 @@
+use std::collections::HashMap;
 use std::env;
 use std::sync::Arc;
 use axum::{Router, routing::post};
@@ -5,13 +6,14 @@ use axum::routing::{get, put};
 use sqlx::PgPool;
 use time::util::local_offset;
 use tokio::sync::broadcast::{channel, Sender};
+use tokio::sync::Mutex;
 use tracing::{info, level_filters::LevelFilter};
 use tracing_subscriber::{EnvFilter, fmt::{self, time::LocalTime}, prelude::*};
 use crate::config::SETTINGS;
 use crate::db::init_db_pool;
 use crate::routes::device::{get_device, post_device, put_device};
 use crate::routes::start::start;
-use crate::services::ping::ws_ping;
+use crate::routes::status::status;
 
 mod auth;
 mod config;
@@ -47,15 +49,17 @@ async fn main() {
     sqlx::migrate!().run(&db).await.unwrap();
 
     let (tx, _) = channel(32);
+
+    let ping_map: HashMap<String, (String, bool)> = HashMap::new();
     
-    let shared_state = Arc::new(AppState { db, ping_send: tx });
+    let shared_state = Arc::new(AppState { db, ping_send: tx, ping_map: Arc::new(Mutex::new(ping_map)) });
 
     let app = Router::new()
         .route("/start", post(start))
         .route("/device", get(get_device))
         .route("/device", put(put_device))
         .route("/device", post(post_device))
-        .route("/status", get(ws_ping))
+        .route("/status", get(status))
         .with_state(shared_state);
 
     let addr = SETTINGS.get_string("serveraddr").unwrap_or("0.0.0.0:7229".to_string());
@@ -69,4 +73,5 @@ async fn main() {
 pub struct AppState {
     db: PgPool,
     ping_send: Sender<String>,
-}
+    ping_map: Arc<Mutex<HashMap<String, (String, bool)>>>,
+}
\ No newline at end of file
-- 
cgit v1.2.3