From 46cb6bcbe8ed6254aa06ff155828666d14ef7bed Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 14 Sep 2025 17:58:59 +0800 Subject: feat: network control --- src/client/connector/connectors/httpconnector.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/client/connector') 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 { + 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(); + } } -- cgit v1.2.3