fix: ios build

This commit is contained in:
Kingtous
2023-04-17 19:26:39 +08:00
parent f56fc6fdb0
commit 83e63d57e1
16 changed files with 171 additions and 96 deletions

View File

@@ -6,12 +6,13 @@ use hbb_common::{
};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
#[cfg(not(any(target_os = "ios")))]
use crate::Connection;
const TIME_HEARTBEAT: Duration = Duration::from_secs(30);
const TIME_CONN: Duration = Duration::from_secs(3);
#[cfg(not(any(target_os = "ios")))]
lazy_static::lazy_static! {
static ref SENDER : Mutex<broadcast::Sender<Vec<i32>>> = Mutex::new(start_hbbs_sync());
}
@@ -21,10 +22,12 @@ pub fn start() {
let _sender = SENDER.lock().unwrap();
}
#[cfg(not(target_os = "ios"))]
pub fn signal_receiver() -> broadcast::Receiver<Vec<i32>> {
SENDER.lock().unwrap().subscribe()
}
#[cfg(not(any(target_os = "ios")))]
fn start_hbbs_sync() -> broadcast::Sender<Vec<i32>> {
let (tx, _rx) = broadcast::channel::<Vec<i32>>(16);
std::thread::spawn(move || start_hbbs_sync_async());
@@ -37,6 +40,7 @@ pub struct StrategyOptions {
pub extra: HashMap<String, String>,
}
#[cfg(not(any(target_os = "ios")))]
#[tokio::main(flavor = "current_thread")]
async fn start_hbbs_sync_async() {
tokio::spawn(async move {