set event stream to None in rust side
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
bfaa463002
commit
d8fe758604
@ -1389,6 +1389,7 @@ class FFI {
|
||||
}
|
||||
}
|
||||
}
|
||||
debugPrint('Exit session event loop');
|
||||
}();
|
||||
// every instance will bind a stream
|
||||
this.id = id;
|
||||
|
@ -134,6 +134,14 @@ impl FlutterHandler {
|
||||
stream.add(EventToUI::Event(out));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn close_event_stream(&mut self) {
|
||||
let mut stream_lock = self.event_stream.write().unwrap();
|
||||
if let Some(stream) = &*stream_lock {
|
||||
stream.add(EventToUI::Event("close".to_owned()));
|
||||
}
|
||||
*stream_lock = None;
|
||||
}
|
||||
}
|
||||
|
||||
impl InvokeUiSession for FlutterHandler {
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
flutter::{session_add, session_start_},
|
||||
ui_interface::{self, *},
|
||||
};
|
||||
use flutter_rust_bridge::{StreamSink, SyncReturn, ZeroCopyBuffer};
|
||||
use flutter_rust_bridge::{StreamSink, SyncReturn};
|
||||
use hbb_common::{
|
||||
config::{self, LocalConfig, PeerConfig, ONLINE},
|
||||
fs, log,
|
||||
@ -131,13 +131,10 @@ pub fn session_login(id: String, password: String, remember: bool) {
|
||||
}
|
||||
|
||||
pub fn session_close(id: String) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
if let Some(stream) = &*session.event_stream.read().unwrap() {
|
||||
stream.add(EventToUI::Event("close".to_owned()));
|
||||
}
|
||||
if let Some(mut session) = SESSIONS.write().unwrap().remove(&id) {
|
||||
session.close_event_stream();
|
||||
session.close();
|
||||
}
|
||||
let _ = SESSIONS.write().unwrap().remove(&id);
|
||||
}
|
||||
|
||||
pub fn session_refresh(id: String) {
|
||||
|
Loading…
Reference in New Issue
Block a user