From 05ac93ec40c1f8344963b735618bff3014fe3fdf Mon Sep 17 00:00:00 2001 From: Kingtous Date: Mon, 17 Apr 2023 00:28:49 +0800 Subject: [PATCH] fix: add_session fix for bridge --- src/api.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/api.rs b/src/api.rs index 187c396d0..a0ea5df1c 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,4 +1,4 @@ -use std::ffi::c_char; +use std::ffi::{c_char}; use crate::{ flutter::{FlutterHandler, SESSIONS}, @@ -9,19 +9,18 @@ use crate::{ // API provided by RustDesk. pub type LoadPluginFunc = fn(*const c_char) -> i32; pub type UnloadPluginFunc = fn(*const c_char) -> i32; -pub type AddSessionFunc = fn(session: Session) -> bool; +pub type AddSessionFunc = fn(session_id: String) -> bool; pub type RemoveSessionFunc = fn(session_id: &String) -> bool; pub type AddSessionHookFunc = fn(session_id: String, key: String, hook: SessionHook) -> bool; pub type RemoveSessionHookFunc = fn(session_id: String, key: &String) -> bool; /// Hooks for session. -#[repr(usize)] #[derive(Clone)] pub enum SessionHook { - OnSessionRgba(fn(&Session, Vec) -> Vec) = 1, + OnSessionRgba(fn(String, Vec) -> Vec), } -#[repr(C)] +// #[repr(C)] pub struct RustDeskApiTable { pub(crate) load_plugin: LoadPluginFunc, pub(crate) unload_plugin: UnloadPluginFunc, @@ -39,13 +38,14 @@ fn unload_plugin(path: *const c_char) -> i32 { PLUGIN_REGISTRAR.unload_plugin(path) } -fn add_session(session: Session) -> bool { - let mut sessions = SESSIONS.write().unwrap(); - if sessions.contains_key(&session.id) { - return false; - } - let _ = sessions.insert(session.id.to_owned(), session); - true +fn add_session(session_id: String) -> bool { + // let mut sessions = SESSIONS.write().unwrap(); + // if sessions.contains_key(&session.id) { + // return false; + // } + // let _ = sessions.insert(session.id.to_owned(), session); + // true + false } fn remove_session(session_id: &String) -> bool {