reqwest-websocket
Provides wrappers for reqwest
to enable websocket connections.
Example
For a full example take a look at hello_world.rs
.
// Extends the reqwest::RequestBuilder to allow websocket upgrades
use RequestBuilderExt;
// don't use `ws://` or `wss://` for the url, but rather `http://` or `https://`
let response = default
.get
.upgrade // prepares the websocket upgrade.
.send
.await?;
// turn the response into a websocket stream
let mut websocket = response.into_websocket.await?;
// the websocket implements `Sink<Message>`.
websocket.send.await?;
// the websocket is also a `TryStream` over `Message`s.
while let Some = websocket.try_next.await?