test2/test2.rs
1use rustwave::{Client, Result};
2
3#[tokio::main]
4async fn main() -> Result<()> {
5 let client = Client::connect("ws://127.0.0.1:8080/chat").await?;
6
7 client.on("message", |data| async move {
8 println!("Got back: {}", data);
9 });
10
11 client.emit("mess", "hello from chat client").await?;
12
13 tokio::time::sleep(std::time::Duration::from_secs(1)).await;
14
15 client.wait().await;
16
17 Ok(())
18}