Expand description
A WebSocket client library that can be compiled to both native and the web (WASM).
Usage:
let options = ewebsock::Options::default();
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);
}§Feature flags
-
tokio— Opt-in to the tokio executor.This adds a lot of dependencies, but may yield lower latency and CPU usage when using
ws_connect.Will ignore any
ControlFlow::Breakreturned from theon_eventcallback.
Structs§
- Options
- Options for a connection.
- WsReceiver
- Receiver for incoming
WsEvents. - WsSender
- This is how you send
WsMessages to the server.
Enums§
Functions§
- connect
- Connect to the given URL, and return a sender and receiver.
- connect_
with_ wakeup - Like
connect, but will call the given wake-up function on each incoming event. - ws_
connect - Connect and call the given event handler on each received event.
- ws_
receive - Connect and call the given event handler on each received event.