This library is an implementation of the WebSocket protocol, which provides a way for two-way communication between a client and server over a single TCP connection. This library provides an easy-to-use, modern, and intuitive WebSocket implementation for both client and server-side applications.
To use this library, add it as a dependency to your Rust project by adding the following line to your Cargo.toml
file:
toml
[dependencies]
web-socket = "0.5"
You can run this example with: cargo run --example minimal
```rust norun use tokio::io::*; use websocket::*;
async fn example
match ws.recv().await? {
Event::Data { ty, data } => {
assert_eq!(ty, DataType::Complete(MessageType::Text));
assert_eq!(&*data, b"Copy Cat!");
}
Event::Ping(data) => ws.send_ping(data).await?,
Event::Pong(..) => {}
Event::Error(..) => return ws.close(CloseCode::ProtocolError).await,
Event::Close { .. } => return ws.close(()).await,
}
}
ws.close("bye!").await
} ```
For more examples, see ./examples directory.
It passed all test of the autobahn testsuite
This project is licensed under Apache License 2.0