mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-18 10:41:03 +03:00
refactor windows specific session (#7170)
1. Modify the process to have the control side lead the session switching: After the control side sends a `LoginRequest`, the controlled side will add all session information and the current session ID in the `LoginResponse`. Upon receiving the `LoginResponse`, the control side will check if the current session ID matches the ID in the `LoginConfigHandler`. If they match, the control side will send the current session ID. If they don't match, a session selection dialog will pop up, the selected session id will be sent. Upon receiving this message, the controlled side will restart if different or sub service if same . 2. Always show physical console session on the top 3. Show running session and distinguish sessions with the same name 4. Not sub service until correct session id is ensured 5. Fix switch sides not work for multisession session 6. Remove all session string join/split except get_available_sessions in windows.rs 7. Fix prelogin, when share rdp is enabled and there is a rdp session, the console is in login screen, get_active_username will be the rdp's username and prelogin will be false, cm can't be created an that causes disconnection in a loop 8. Rename all user session to windows session Known issue: 1. Use current process session id for `run_as_user`, sahil says it can be wrong but I didn't reproduce. 2. Have not change tray process to current session 3. File transfer doesn't update home directory when session changed 4. When it's in login screen, remote file directory is empty, because cm have not start up Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -1003,7 +1003,7 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reconnect(&self, force_relay: bool, user_session_id: String) {
|
||||
pub fn reconnect(&self, force_relay: bool) {
|
||||
// 1. If current session is connecting, do not reconnect.
|
||||
// 2. If the connection is established, send `Data::Close`.
|
||||
// 3. If the connection is disconnected, do nothing.
|
||||
@@ -1023,9 +1023,6 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
if true == force_relay {
|
||||
self.lc.write().unwrap().force_relay = true;
|
||||
}
|
||||
if !user_session_id.is_empty() {
|
||||
self.lc.write().unwrap().selected_user_session_id = user_session_id;
|
||||
}
|
||||
let mut lock = self.thread.lock().unwrap();
|
||||
// No need to join the previous thread, because it will exit automatically.
|
||||
// And the previous thread will not change important states.
|
||||
@@ -1254,6 +1251,19 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
pub fn close_voice_call(&self) {
|
||||
self.send(Data::CloseVoiceCall);
|
||||
}
|
||||
|
||||
pub fn send_selected_session_id(&self, sid: String) {
|
||||
if let Ok(sid) = sid.parse::<u32>() {
|
||||
self.lc.write().unwrap().selected_windows_session_id = Some(sid);
|
||||
let mut misc = Misc::new();
|
||||
misc.set_selected_sid(sid);
|
||||
let mut msg = Message::new();
|
||||
msg.set_misc(misc);
|
||||
self.send(Data::Message(msg));
|
||||
} else {
|
||||
log::error!("selected invalid sid: {}", sid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {
|
||||
@@ -1313,7 +1323,7 @@ pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {
|
||||
fn next_rgba(&self, display: usize);
|
||||
#[cfg(all(feature = "gpucodec", feature = "flutter"))]
|
||||
fn on_texture(&self, display: usize, texture: *mut c_void);
|
||||
fn set_multiple_user_session(&self, sessions: Vec<hbb_common::message_proto::RdpUserSession>);
|
||||
fn set_multiple_windows_session(&self, sessions: Vec<WindowsSession>);
|
||||
}
|
||||
|
||||
impl<T: InvokeUiSession> Deref for Session<T> {
|
||||
@@ -1355,8 +1365,8 @@ impl<T: InvokeUiSession> Interface for Session<T> {
|
||||
handle_login_error(self.lc.clone(), err, self)
|
||||
}
|
||||
|
||||
fn set_multiple_user_sessions(&self, sessions: Vec<hbb_common::message_proto::RdpUserSession>) {
|
||||
self.ui_handler.set_multiple_user_session(sessions);
|
||||
fn set_multiple_windows_session(&self, sessions: Vec<WindowsSession>) {
|
||||
self.ui_handler.set_multiple_windows_session(sessions);
|
||||
}
|
||||
|
||||
fn handle_peer_info(&self, mut pi: PeerInfo) {
|
||||
@@ -1419,6 +1429,19 @@ impl<T: InvokeUiSession> Interface for Session<T> {
|
||||
crate::platform::windows::add_recent_document(&path);
|
||||
}
|
||||
}
|
||||
if !pi.windows_sessions.sessions.is_empty() {
|
||||
let selected = self
|
||||
.lc
|
||||
.read()
|
||||
.unwrap()
|
||||
.selected_windows_session_id
|
||||
.to_owned();
|
||||
if selected == Some(pi.windows_sessions.current_sid) {
|
||||
self.send_selected_session_id(pi.windows_sessions.current_sid.to_string());
|
||||
} else {
|
||||
self.set_multiple_windows_session(pi.windows_sessions.sessions.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream) {
|
||||
|
||||
Reference in New Issue
Block a user