summaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-02-12 15:05:03 +0100
committerGitHub <[email protected]>2024-02-12 15:05:03 +0100
commitca395b81bcadb9dde9214098f2cab0c7a3561574 (patch)
tree055bae9ef4e65f53b826b240f0b8e3b15b73693e /src/services
parente4832b4cf36ba0eaed298ee458498eddd7176590 (diff)
parente50a868f69b602cc0bc84d51e9940878924f49ef (diff)
downloadwebol-ca395b81bcadb9dde9214098f2cab0c7a3561574.tar
webol-ca395b81bcadb9dde9214098f2cab0c7a3561574.tar.gz
webol-ca395b81bcadb9dde9214098f2cab0c7a3561574.zip
Merge pull request #13 from FxQnLr/config
Config
Diffstat (limited to 'src/services')
-rw-r--r--src/services/ping.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/services/ping.rs b/src/services/ping.rs
index 7d71218..9b164c8 100644
--- a/src/services/ping.rs
+++ b/src/services/ping.rs
@@ -10,7 +10,7 @@ use time::{Duration, Instant};
10use tokio::sync::broadcast::Sender; 10use tokio::sync::broadcast::Sender;
11use tracing::{debug, error, trace}; 11use tracing::{debug, error, trace};
12use crate::AppState; 12use crate::AppState;
13use crate::config::SETTINGS; 13use crate::config::Config;
14use crate::db::Device; 14use crate::db::Device;
15 15
16pub type StatusMap = DashMap<String, Value>; 16pub type StatusMap = DashMap<String, Value>;
@@ -21,7 +21,7 @@ pub struct Value {
21 pub online: bool 21 pub online: bool
22} 22}
23 23
24pub async fn spawn(tx: Sender<BroadcastCommands>, device: Device, uuid: String, ping_map: &StatusMap, db: &PgPool) { 24pub async fn spawn(tx: Sender<BroadcastCommands>, config: &Config, device: Device, uuid: String, ping_map: &StatusMap, db: &PgPool) {
25 let timer = Instant::now(); 25 let timer = Instant::now();
26 let payload = [0; 8]; 26 let payload = [0; 8];
27 27
@@ -40,7 +40,7 @@ pub async fn spawn(tx: Sender<BroadcastCommands>, device: Device, uuid: String,
40 error!("{}", ping.to_string()); 40 error!("{}", ping.to_string());
41 msg = Some(BroadcastCommands::Error(uuid.clone())); 41 msg = Some(BroadcastCommands::Error(uuid.clone()));
42 } 42 }
43 if timer.elapsed() >= Duration::minutes(SETTINGS.get_int("pingtimeout").unwrap_or(10)) { 43 if timer.elapsed() >= Duration::minutes(config.pingtimeout) {
44 msg = Some(BroadcastCommands::Timeout(uuid.clone())); 44 msg = Some(BroadcastCommands::Timeout(uuid.clone()));
45 } 45 }
46 } else { 46 } else {