diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-09-14 17:58:59 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-09-14 17:58:59 +0800 |
| commit | 46cb6bcbe8ed6254aa06ff155828666d14ef7bed (patch) | |
| tree | d5254d653c632f83d74d8ea8688ac2fc3155c0b2 /src/client/connector | |
| parent | 35466de9f0ccabf88e1dfaa97fe39e5e74614f52 (diff) | |
feat: network control
Diffstat (limited to 'src/client/connector')
| -rw-r--r-- | src/client/connector/connectors/httpconnector.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/client/connector/connectors/httpconnector.rs b/src/client/connector/connectors/httpconnector.rs index fb97cc4..2d58d1d 100644 --- a/src/client/connector/connectors/httpconnector.rs +++ b/src/client/connector/connectors/httpconnector.rs @@ -3,10 +3,11 @@ use reqwest::{ blocking::{Client, Response}, }; -use crate::connector::*; +use crate::{connector::*, executor::tasks::TASKS}; use std::{thread::sleep, time::Duration}; pub(crate) struct HTTPConnector { + network_updater: Executor, pull_url: Url, ntfy_url: Url, client: Client, @@ -15,7 +16,9 @@ pub(crate) struct HTTPConnector { impl HTTPConnector { pub fn new(pull_url: &str, ntfy_url: &str) -> std::result::Result<Self, url::ParseError> { + assert_eq!(TASKS[2].name, "network"); Ok(Self { + network_updater: Executor::new(&TASKS[2], ["on".to_string()]).unwrap(), prev: String::new(), pull_url: Url::parse(pull_url)?, ntfy_url: Url::parse(ntfy_url)?, @@ -88,4 +91,8 @@ impl Connection for HTTPConnector { } false } + + fn force_network(&mut self) { + _ = self.network_updater.run(); + } } |
