#websocket-client #native #web #portable

ewebsock

WebSocket client that works natively and on the web (WASM)

9 releases (breaking)

0.8.0 Nov 11, 2024
0.6.0 May 21, 2024
0.5.0 Feb 26, 2024
0.4.0 Oct 7, 2023
0.1.0 Feb 23, 2022

#16 in WebSocket

Download history 3388/week @ 2024-08-19 4277/week @ 2024-08-26 2668/week @ 2024-09-02 3661/week @ 2024-09-09 2907/week @ 2024-09-16 3739/week @ 2024-09-23 4371/week @ 2024-09-30 5303/week @ 2024-10-07 5517/week @ 2024-10-14 3648/week @ 2024-10-21 2346/week @ 2024-10-28 3060/week @ 2024-11-04 6323/week @ 2024-11-11 4361/week @ 2024-11-18 4956/week @ 2024-11-25 5176/week @ 2024-12-02

20,932 downloads per month
Used in 41 crates (4 directly)

MIT/Apache

43KB
667 lines

ewebsock

github Latest version Documentation unsafe forbidden Build Status MIT Apache

This is a simple WebSocket library for Rust which can be compiled to both native and web (WASM).

Usage

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);
}

Testing

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)

Dependencies

~0.2–8.5MB
~74K SLoC