rustwave 0.1.0

A lightweight async event-driven WebSocket framework for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use rustwave::{Client, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let client = Client::connect("ws://127.0.0.1:8080/chat").await?;

    client.on("message", |data| async move {
        println!("Got back: {}", data);
    });

    client.emit("mess", "hello from chat client").await?;

    tokio::time::sleep(std::time::Duration::from_secs(1)).await;

    client.wait().await;

    Ok(())
}