From 27f90bd85f2abf2ecdac69880801d657f125b6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?cel=20=F0=9F=8C=B8?= Date: Sun, 22 Dec 2024 19:55:48 +0000 Subject: [PATCH] stream and sink split --- jabber/src/client.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/jabber/src/client.rs b/jabber/src/client.rs index 32b8f6e..f5d5dc7 100644 --- a/jabber/src/client.rs +++ b/jabber/src/client.rs @@ -349,12 +349,11 @@ mod tests { sleep(Duration::from_secs(5)).await; let jid = client.jid.clone(); let server = client.server.clone(); - let mut client = Arc::new(Mutex::new(client)); + let (mut write, mut read) = client.split(); tokio::join!( async { - let mut client = client.lock().await; - client + write .send(Stanza::Iq(Iq { from: Some(jid.clone()), id: "c2s1".to_string(), @@ -365,10 +364,7 @@ mod tests { errors: Vec::new(), })) .await; - }, - async { - let mut client = client.lock().await; - client + write .send(Stanza::Iq(Iq { from: Some(jid.clone()), id: "c2s2".to_string(), @@ -381,7 +377,7 @@ mod tests { .await; }, async { - while let Some(stanza) = client.lock().await.next().await { + while let Some(stanza) = read.next().await { info!("{:#?}", stanza); } }