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
use rustwave::{Client, Result};

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

    client.on("pong", |data| async move {
        println!("Server replied: {}", data);
    });

    client.emit("ping", "").await?;

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

    Ok(())
}