diff --git a/src/lib.rs b/src/lib.rs index 7cb4451..655a09f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,13 +47,13 @@ pub async fn connect_to_server( } } Ok((mut ws, _)) => { + debug!("Connection successful"); let (to_core_sender, to_core_reciever) = async_channel::bounded::(MAX_MESSAGE); let (to_app_events, from_app_events) = async_channel::bounded::(MAX_MESSAGE); - let res: AppSender = to_core_sender; // to core: endpoint -> remote - let rec: AppReceiver = from_app_events; // from app: remote -> endpoint + debug!("created channels for oneshote"); - if let Err(e) = result_oneshot.send(Ok((res.clone(), rec))) { + if let Err(e) = result_oneshot.send(Ok((to_core_sender as AppSender, from_app_events as AppReceiver))) { if let Err(e2) = ws.close(None).await { error!("Could not close connection to websocket! {e2}"); } @@ -63,12 +63,11 @@ pub async fn connect_to_server( let (ws_sender, ws_recv) = ws.split(); - let to_app: AppSender = to_app_events; let receiver_is_closed = Arc::new(AtomicBool::new(false)); let moved_copy = receiver_is_closed.clone(); tokio::spawn(async move { - listen_to_ws_task(to_app, moved_copy, ws_recv) + listen_to_ws_task(to_app_events as AppSender, moved_copy, ws_recv) }); tokio::spawn(async move {