mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge pull request #2029 from 21pages/stop-service
close all connections when stop service
This commit is contained in:
@@ -250,14 +250,7 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
ipc::Data::Close => {
|
||||
conn.close_manually = true;
|
||||
let mut misc = Misc::new();
|
||||
misc.set_close_reason("Closed manually by the peer".into());
|
||||
let mut msg_out = Message::new();
|
||||
msg_out.set_misc(misc);
|
||||
conn.send(msg_out).await;
|
||||
conn.on_close("Close requested from connection manager", false).await;
|
||||
SESSIONS.lock().unwrap().remove(&conn.lr.my_id);
|
||||
conn.on_close_manually("connection manager").await;
|
||||
break;
|
||||
}
|
||||
ipc::Data::ChatMessage{text} => {
|
||||
@@ -404,6 +397,18 @@ impl Connection {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
match &msg.union {
|
||||
Some(message::Union::Misc(m)) => {
|
||||
match &m.union {
|
||||
Some(misc::Union::StopService(_)) => {
|
||||
conn.on_close_manually("stop service").await;
|
||||
break;
|
||||
}
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if let Err(err) = conn.stream.send(msg).await {
|
||||
conn.on_close(&err.to_string(), false).await;
|
||||
break;
|
||||
@@ -1490,6 +1495,18 @@ impl Connection {
|
||||
self.port_forward_socket.take();
|
||||
}
|
||||
|
||||
async fn on_close_manually(&mut self, close_from: &str) {
|
||||
self.close_manually = true;
|
||||
let mut misc = Misc::new();
|
||||
misc.set_close_reason("Closed manually by the peer".into());
|
||||
let mut msg_out = Message::new();
|
||||
msg_out.set_misc(misc);
|
||||
self.send(msg_out).await;
|
||||
self.on_close(&format!("Close requested from {}", close_from), false)
|
||||
.await;
|
||||
SESSIONS.lock().unwrap().remove(&self.lr.my_id);
|
||||
}
|
||||
|
||||
fn read_dir(&mut self, dir: &str, include_hidden: bool) {
|
||||
let dir = dir.to_string();
|
||||
self.send_fs(ipc::FS::ReadDir {
|
||||
|
||||
Reference in New Issue
Block a user