connect now returns a 'to close' flag
This commit is contained in:
parent
c5e733b71d
commit
ed434303de
1 changed files with 6 additions and 5 deletions
11
src/lib.rs
11
src/lib.rs
|
@ -40,7 +40,7 @@ pub type AppReceiver = Receiver<ApplicationMessage>;
|
||||||
pub async fn connect_to_server(
|
pub async fn connect_to_server(
|
||||||
connection_string: String,
|
connection_string: String,
|
||||||
rt: Handle,
|
rt: Handle,
|
||||||
) -> Result<(AppSender, AppReceiver), tungstenite_error> {
|
) -> Result<(AppSender, AppReceiver, Arc<AtomicBool>), tungstenite_error> {
|
||||||
|
|
||||||
debug!("Connecting to parent!");
|
debug!("Connecting to parent!");
|
||||||
|
|
||||||
|
@ -57,14 +57,15 @@ pub async fn connect_to_server(
|
||||||
let (ws_sender, ws_recv) = ws.split();
|
let (ws_sender, ws_recv) = ws.split();
|
||||||
|
|
||||||
let receiver_is_closed = Arc::new(AtomicBool::new(false));
|
let receiver_is_closed = Arc::new(AtomicBool::new(false));
|
||||||
let moved_copy = receiver_is_closed.clone();
|
let rec_is_closed1 = receiver_is_closed.clone();
|
||||||
|
let rec_is_closed2 = receiver_is_closed.clone();
|
||||||
|
|
||||||
rt.spawn(listen_to_ws_task(to_app_events as AppSender, moved_copy, ws_recv));
|
rt.spawn(listen_to_ws_task(to_app_events as AppSender, rec_is_closed1, ws_recv));
|
||||||
|
|
||||||
rt.spawn(send_to_wc_task(to_core_reciever, receiver_is_closed, ws_sender));
|
rt.spawn(send_to_wc_task(to_core_reciever, rec_is_closed2, ws_sender));
|
||||||
|
|
||||||
info!("Websocket connect successfully");
|
info!("Websocket connect successfully");
|
||||||
return Ok((to_core_sender as AppSender, from_app_events as AppReceiver));
|
return Ok((to_core_sender as AppSender, from_app_events as AppReceiver, receiver_is_closed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue