implement functional draft version

This commit is contained in:
SoLongAndThanksForAllThePizza
2022-05-29 04:39:12 +08:00
parent f56dcc9e6c
commit e836b7fcfb
6 changed files with 385 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
use crate::client::file_trait::FileManager;
use crate::flutter::connection_manager::{self, get_clients_length, get_clients_state};
use crate::flutter::{self, make_fd_to_json, Session};
use crate::start_server;
use crate::ui_interface;
use flutter_rust_bridge::{StreamSink, ZeroCopyBuffer};
use hbb_common::ResultType;
@@ -49,7 +50,7 @@ pub fn start_rgba_stream(s: StreamSink<ZeroCopyBuffer<Vec<u8>>>) -> ResultType<(
/// FFI for **get** commands which are idempotent.
/// Return result in c string.
///
///
/// # Arguments
///
/// * `name` - name of the command
@@ -515,10 +516,9 @@ unsafe extern "C" fn set_by_name(name: *const c_char, value: *const c_char) {
Config::set_option("stop-service".into(), "Y".into());
crate::rendezvous_mediator::RendezvousMediator::restart();
}
#[cfg(target_os = "android")]
"start_service" => {
Config::set_option("stop-service".into(), "".into());
crate::rendezvous_mediator::RendezvousMediator::restart();
start_server(false);
}
#[cfg(target_os = "android")]
"close_conn" => {

View File

@@ -287,12 +287,26 @@ pub fn check_zombie() {
});
}
/// Start the host server that allows the remote peer to control the current machine.
///
/// # Arguments
///
/// * `is_server` - Whether the current client is definitely the server.
/// If true, the server will be started.
/// Otherwise, client will check if there's already a server and start one if not.
#[cfg(any(target_os = "android", target_os = "ios"))]
#[tokio::main]
pub async fn start_server(is_server: bool) {
crate::RendezvousMediator::start_all().await;
}
/// Start the host server that allows the remote peer to control the current machine.
///
/// # Arguments
///
/// * `is_server` - Whether the current client is definitely the server.
/// If true, the server will be started.
/// Otherwise, client will check if there's already a server and start one if not.
#[cfg(not(any(target_os = "android", target_os = "ios")))]
#[tokio::main]
pub async fn start_server(is_server: bool) {