Crates.io | ewebsock |
lib.rs | ewebsock |
version | 0.7.0 |
source | src |
created_at | 2022-02-23 12:50:27.539769 |
updated_at | 2024-10-10 13:07:25.285776 |
description | WebSocket client that works natively and on the web (WASM) |
homepage | https://github.com/rerun-io/ewebsock |
repository | https://github.com/rerun-io/ewebsock |
max_upload_size | |
id | 537852 |
size | 42,632 |
This is a simple WebSocket library for Rust which can be compiled to both native and web (WASM).
let options = ewebsock::Options::default();
// see documentation for more options
let (mut sender, receiver) = ewebsock::connect("ws://example.com", options).unwrap();
sender.send(ewebsock::WsMessage::Text("Hello!".into()));
while let Some(event) = receiver.try_recv() {
println!("Received {:?}", event);
}
First start the example echo server with:
cargo r -p echo_server
Then test the library with:
# native mode
cargo run -p example_app
# web mode
# install trunk with `cargo install trunk` - https://trunkrs.dev/
(cd example_app && trunk serve)