Struct web_socket::WebSocket
source · pub struct WebSocket<const SIDE: bool, Stream> {
pub stream: Stream,
pub max_payload_len: usize,
/* private fields */
}
Expand description
WebSocket implementation for both client and server
Fields§
§stream: Stream
it is a low-level abstraction that represents the underlying byte stream over which WebSocket messages are exchanged.
max_payload_len: usize
maximum allowed payload length in bytes
Implementations§
source§impl<const SIDE: bool, W: Unpin + AsyncWrite> WebSocket<SIDE, W>
impl<const SIDE: bool, W: Unpin + AsyncWrite> WebSocket<SIDE, W>
sourcepub async fn send_ping(&mut self, data: impl AsRef<[u8]>) -> Result<()>
pub async fn send_ping(&mut self, data: impl AsRef<[u8]>) -> Result<()>
A Ping frame may serve either as a keepalive or as a means to verify that the remote endpoint is still responsive.
sourcepub async fn send_pong(&mut self, data: impl AsRef<[u8]>) -> Result<()>
pub async fn send_pong(&mut self, data: impl AsRef<[u8]>) -> Result<()>
Sends a pong frame in response to a ping frame received from the WebSocket endpoint.