pub struct WsConnection<F> { /* private fields */ }Expand description
An established WebSocket client connection.
This value retains the opening-handshake response, the WebSocket codec, and the underlying I/O stream.
Implementations§
Source§impl<F> WsConnection<F>
impl<F> WsConnection<F>
Source§impl<F> WsConnection<F>
impl<F> WsConnection<F>
Sourcepub fn sink(&self) -> WsSink
pub fn sink(&self) -> WsSink
Returns a sink for sending messages over this connection.
All sinks of a connection share the same state, so a message cannot be sent through any of them once one has sent a close message.
Sourcepub fn into_inner(self) -> (Io<F>, Codec, ClientResponse)
pub fn into_inner(self) -> (Io<F>, Codec, ClientResponse)
Consumes the connection and returns its I/O stream, codec, and opening-handshake response.
Source§impl WsConnection<Sealed>
impl WsConnection<Sealed>
Sourcepub fn receiver(self) -> Receiver<Result<Frame, WsError<()>>>
pub fn receiver(self) -> Receiver<Result<Frame, WsError<()>>>
Starts the WebSocket dispatcher and returns a channel of received frames.
The dispatcher runs in a spawned task. Protocol and connection errors are delivered through the returned channel. A close frame from the peer is answered automatically, unless a close message has already been sent through a sink of this connection. Dropping the receiver sends a close frame and closes the connection once the peer responds or the closing-handshake timeout expires.
Source§impl<F: Filter> WsConnection<F>
impl<F: Filter> WsConnection<F>
Sourcepub fn seal(self) -> WsConnection<Sealed>
pub fn seal(self) -> WsConnection<Sealed>
Erases the concrete I/O filter type.
Sourcepub fn into_transport(self) -> Io<Layer<WsTransport, F>>
pub fn into_transport(self) -> Io<Layer<WsTransport, F>>
Converts the connection into a binary WebSocket transport.