control end close message

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2022-07-18 11:05:19 +08:00
parent 8667d68c6f
commit 0812dc79b8
2 changed files with 9 additions and 0 deletions

View File

@ -1133,6 +1133,10 @@ impl Connection {
Some(Instant::now().into()),
);
}
Some(misc::Union::CloseReason(_)) => {
self.on_close("Peer close", true);
return false;
}
_ => {}
},
_ => {}

View File

@ -1633,6 +1633,11 @@ impl Remote {
// log::info!("new msg from ui, {}",data);
match data {
Data::Close => {
let mut misc = Misc::new();
misc.set_close_reason("".to_owned());
let mut msg = Message::new();
msg.set_misc(misc);
allow_err!(peer.send(&msg).await);
return false;
}
Data::Login((password, remember)) => {