aboutsummaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-06-17 10:35:06 +0200
committerGitHub <[email protected]>2024-06-17 10:35:06 +0200
commitc6baa076dc41dd43b3888d713fcf39fa901d2cd3 (patch)
treeba345251131779e76c076d60971e4f7f066bf146 /src/services
parent04cd0aee6d000073e49b80a530a40cdb176f7f10 (diff)
parent8268b826cc45f5b2bd31b72339cc310789ab22d4 (diff)
downloadwebol-c6baa076dc41dd43b3888d713fcf39fa901d2cd3.tar
webol-c6baa076dc41dd43b3888d713fcf39fa901d2cd3.tar.gz
webol-c6baa076dc41dd43b3888d713fcf39fa901d2cd3.zip
Merge pull request #37 from FxQnLr/time_update
Time update
Diffstat (limited to 'src/services')
-rw-r--r--src/services/ping.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/services/ping.rs b/src/services/ping.rs
index 4e0ffcf..69c911f 100644
--- a/src/services/ping.rs
+++ b/src/services/ping.rs
@@ -2,8 +2,8 @@ use crate::config::Config;
2use crate::storage::Device; 2use crate::storage::Device;
3use dashmap::DashMap; 3use dashmap::DashMap;
4use ipnetwork::IpNetwork; 4use ipnetwork::IpNetwork;
5use std::fmt::Display; 5use std::{fmt::Display, time::Instant};
6use time::{Duration, Instant}; 6use time::Duration;
7use tokio::sync::broadcast::Sender; 7use tokio::sync::broadcast::Sender;
8use tracing::{debug, error, trace}; 8use tracing::{debug, error, trace};
9 9
@@ -12,7 +12,7 @@ pub type StatusMap = DashMap<String, Value>;
12#[derive(Debug, Clone)] 12#[derive(Debug, Clone)]
13pub struct Value { 13pub struct Value {
14 pub ip: IpNetwork, 14 pub ip: IpNetwork,
15 pub eta: i64, 15 pub eta: u64,
16 pub online: bool, 16 pub online: bool,
17} 17}
18 18
@@ -56,12 +56,12 @@ pub async fn spawn(
56 56
57 let _ = tx.send(msg.clone()); 57 let _ = tx.send(msg.clone());
58 if msg.command == BroadcastCommands::Success { 58 if msg.command == BroadcastCommands::Success {
59 if timer.elapsed().whole_seconds() > config.pingthreshold { 59 if timer.elapsed().as_secs() > config.pingthreshold {
60 let newtimes = if let Some(mut oldtimes) = device.times { 60 let newtimes = if let Some(mut oldtimes) = device.times {
61 oldtimes.push(timer.elapsed().whole_seconds()); 61 oldtimes.push(timer.elapsed().as_secs());
62 oldtimes 62 oldtimes
63 } else { 63 } else {
64 vec![timer.elapsed().whole_seconds()] 64 vec![timer.elapsed().as_secs()]
65 }; 65 };
66 66
67 let updatedev = Device { 67 let updatedev = Device {