| Crates.io | reconnecting-websocket |
| lib.rs | reconnecting-websocket |
| version | 0.3.2 |
| created_at | 2024-07-14 18:39:14.703274+00 |
| updated_at | 2024-07-26 18:56:01.812144+00 |
| description | A wrapper around gloo::net::websocket::futures::WebSocket that reconnects when the socket drops. Uses exponential-backoff::Backoff to determine the delay between reconnects |
| homepage | https://github.com/cs2dsb/reconnecting-websocket.rs |
| repository | https://github.com/cs2dsb/reconnecting-websocket.rs |
| max_upload_size | |
| id | 1303183 |
| size | 66,472 |
A wrapper around WebSocket that reconnects when the socket
drops. Uses Backoff to determine the delay between reconnects
tracing - enables the tracing crate and logs everything it's doingstate-events - changes the Item type of the stream to be an enum that is either a message or
a status change Both are enabled by defaultInput means stuff you want to send from this client to the server (Sink)
Outut means stuff you want to receive back from the server (Source)
TryFrom for Message for your input type
TryFrom::Error type must implement DebugTryFrom<Message> for your output type
TryFrom::Error type must implement DebugUnpin and, if using tracing feature, DebugSocketBuilder to set the URL and configure backoff. get_proto_and_host can help
constructing the URL relative to the current window.locationSocketBuilder::open to connect the socket. The errors open returns are likely fatal
(invalid URL, blocked port), see WebSocket::open for details. The first connect is done
in the builder so it fails fast if these fatal errors occur but the same kind of error can
also occur on any reconnect and be returned by the Socket Stream implementationSocket can then be polled to get incoming messages. Socket::send can be
called to send messages or Socket::get_sender can be used to get an UnboundedSender.
Socket::close or dropping it will drop the inner WebSocket which sends a close frame
and cleans up the event handlers