Return entire packet in ConnTx::recv

This commit is contained in:
Joscha 2022-08-20 20:18:43 +02:00
parent 741d6c8548
commit 49b37649e3
2 changed files with 22 additions and 22 deletions

View file

@ -46,8 +46,14 @@ async fn main() -> Result<(), Box<dyn Error>> {
let (ws, _) = tokio_tungstenite::connect_async(URI).await?;
let (tx, mut rx) = euphoxide::conn::wrap(ws);
loop {
let data = rx.recv().await?;
while let Some(packet) = rx.recv().await {
let data = match packet.content {
Ok(data) => data,
Err(err) => {
println!("Error for {}: {err}", packet.r#type);
continue;
}
};
match data {
Data::HelloEvent(event) => println!("Connected with id {}", event.session.id),
Data::SnapshotEvent(event) => {