#[cfg(feature = "async")]
use futures::StreamExt;
#[cfg(feature = "async")]
use teamtalk::{Client, Event};
#[cfg(feature = "async")]
fn main() -> teamtalk::Result<()> {
let client = Client::new()?;
let mut stream = client.into_async();
futures::executor::block_on(async {
let _ = stream
.wait_for_predicate(|event, _| {
matches!(event, Event::ConnectionLost | Event::ConnectFailed)
})
.await;
if let Some((event, _msg)) = stream.next().await
&& matches!(event, Event::ConnectionLost | Event::ConnectFailed)
{
}
});
stream.shutdown();
let _client = stream.into_client();
Ok(())
}
#[cfg(not(feature = "async"))]
fn main() {
eprintln!("Enable the async feature: cargo run --example async_event_stream --features async");
}