Crate tokio_tungstenite [] [src]

Async WebSocket usage.

This library is an implementation of WebSocket handshakes and streams. It is based on the crate which implements all required WebSocket protocol logic. So this crate basically just brings tokio support / tokio integration to it.

Each WebSocket stream implements the required Stream and Sink traits, so the socket is just a stream of messages coming in and going out.

Modules

stream

Convenience wrapper for streams to switch between plain TCP and TLS at runtime.

Structs

AcceptAsync

Future returned from accept_async() which will resolve once the connection handshake has finished.

ConnectAsync

Future returned from client_async() which will resolve once the connection handshake has finished.

Request

A WebSocket request

WebSocketStream

A wrapper around an underlying raw stream which implements the WebSocket protocol.

Functions

accept_async

Accepts a new WebSocket connection with the provided stream.

client_async

Creates a WebSocket handshake from a request and a stream. For convenience, the user may call this with a url string, a URL, or a Request. Calling with Request allows the user to add a WebSocket protocol or other custom headers.

connect_async

Connect to a given URL.