This is a simple WebSocket library for Rust which can be compiled to both native and web (WASM).
let (mut sender, receiver) = ewebsock::connect("ws://example.com").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 native library with:
cargo run -p example_app
And the web library with:
./example_app/start_server.sh &
./example_app/build_web.sh --open