diff --git a/src/lib.rs b/src/lib.rs index 1de018f..fa2168c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ use async_channel::{Receiver, Sender}; use futures_util::stream::{SplitSink, SplitStream, StreamExt}; use futures_util::SinkExt; use serde::{Serialize, Deserialize}; +use tokio::runtime::Handle; use tokio::{ net::TcpStream, sync::oneshot @@ -34,7 +35,8 @@ pub type AppReceiver = Receiver; #[instrument(skip(result_oneshot))] pub async fn connect_to_server( connection_string: String, - result_oneshot: oneshot::Sender> + result_oneshot: oneshot::Sender>, + rt: Handle, ) { debug!("Connecting to parent!"); @@ -67,11 +69,11 @@ pub async fn connect_to_server( let receiver_is_closed = Arc::new(AtomicBool::new(false)); let moved_copy = receiver_is_closed.clone(); - tokio::spawn(async move { + rt.spawn(async move { listen_to_ws_task(to_app_events as AppSender, moved_copy, ws_recv) }); - tokio::spawn(async move { + rt.spawn(async move { send_to_wc_task(to_core_reciever, receiver_is_closed, ws_sender) });