mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-16 04:56:18 +00:00
VideoConnCount for future use
This commit is contained in:
@@ -3,9 +3,7 @@ use hbb_common::password_security;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
bytes::Bytes,
|
||||
config::{
|
||||
self, Config, LocalConfig, PeerConfig, CONNECT_TIMEOUT, RENDEZVOUS_PORT,
|
||||
},
|
||||
config::{self, Config, LocalConfig, PeerConfig, CONNECT_TIMEOUT, RENDEZVOUS_PORT},
|
||||
directories_next,
|
||||
futures::future::join_all,
|
||||
log,
|
||||
@@ -22,6 +20,7 @@ use serde_derive::Serialize;
|
||||
use std::process::Child;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
@@ -69,6 +68,8 @@ lazy_static::lazy_static! {
|
||||
static ref TEMPORARY_PASSWD : Arc<Mutex<String>> = Arc::new(Mutex::new("".to_owned()));
|
||||
}
|
||||
|
||||
pub static VIDEO_CONN_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
lazy_static::lazy_static! {
|
||||
static ref OPTION_SYNCED: Arc<Mutex<bool>> = Default::default();
|
||||
@@ -426,7 +427,7 @@ pub fn set_socks(proxy: String, username: String, password: String) {
|
||||
pub fn get_proxy_status() -> bool {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
return ipc::get_proxy_status();
|
||||
|
||||
|
||||
// Currently, only the desktop version has proxy settings.
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
return false;
|
||||
@@ -723,24 +724,29 @@ pub fn change_id(id: String) {
|
||||
pub fn http_request(url: String, method: String, body: Option<String>, header: String) {
|
||||
// Respond to concurrent requests for resources
|
||||
let current_request = ASYNC_HTTP_STATUS.clone();
|
||||
current_request.lock().unwrap().insert(url.clone()," ".to_owned());
|
||||
current_request
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(url.clone(), " ".to_owned());
|
||||
std::thread::spawn(move || {
|
||||
let res = match crate::http_request_sync(url.clone(), method, body, header) {
|
||||
Err(err) => { log::error!("{}", err); err.to_string() },
|
||||
Ok(text) => text,
|
||||
};
|
||||
current_request.lock().unwrap().insert(url,res);
|
||||
let res = match crate::http_request_sync(url.clone(), method, body, header) {
|
||||
Err(err) => {
|
||||
log::error!("{}", err);
|
||||
err.to_string()
|
||||
}
|
||||
Ok(text) => text,
|
||||
};
|
||||
current_request.lock().unwrap().insert(url, res);
|
||||
});
|
||||
}
|
||||
#[inline]
|
||||
pub fn get_async_http_status(url: String) -> Option<String> {
|
||||
match ASYNC_HTTP_STATUS.lock().unwrap().get(&url) {
|
||||
None => {None}
|
||||
Some(_str) => {Some(_str.to_string())}
|
||||
None => None,
|
||||
Some(_str) => Some(_str.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[inline]
|
||||
pub fn post_request(url: String, body: String, header: String) {
|
||||
*ASYNC_JOB_STATUS.lock().unwrap() = " ".to_owned();
|
||||
@@ -1116,6 +1122,9 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
|
||||
*TEMPORARY_PASSWD.lock().unwrap() = value;
|
||||
}
|
||||
}
|
||||
Ok(Some(ipc::Data::VideoConnCount(Some(n)))) => {
|
||||
VIDEO_CONN_COUNT.store(n, Ordering::Relaxed);
|
||||
}
|
||||
Ok(Some(ipc::Data::OnlineStatus(Some((mut x, _c))))) => {
|
||||
if x > 0 {
|
||||
x = 1
|
||||
@@ -1145,6 +1154,7 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
|
||||
c.send(&ipc::Data::Options(None)).await.ok();
|
||||
c.send(&ipc::Data::Config(("id".to_owned(), None))).await.ok();
|
||||
c.send(&ipc::Data::Config(("temporary-password".to_owned(), None))).await.ok();
|
||||
c.send(&ipc::Data::VideoConnCount(None)).await.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user