Struct tungstenite::protocol::WebSocket
[−]
[src]
pub struct WebSocket<Stream> { /* fields omitted */ }
WebSocket input-output stream.
This is THE structure you want to create to me able to talk the WebSocket protocol.
It may be created by calling connect
, accept
or client
functions.
Methods
impl<Stream> WebSocket<Stream>
[src]
fn from_raw_socket(stream: Stream, role: Role) -> Self
Convert a raw socket into a WebSocket without performing a handshake.
fn from_partially_read(stream: Stream, part: Vec<u8>, role: Role) -> Self
Convert a raw socket into a WebSocket without performing a handshake.
fn get_ref(&self) -> &Stream
Returns a shared reference to the inner stream.
fn get_mut(&mut self) -> &mut Stream
Returns a mutable reference to the inner stream.
impl<Stream: Read + Write> WebSocket<Stream>
[src]
fn read_message(&mut self) -> Result<Message>
Read a message from stream, if possible.
This function sends pong and close responses automatically. However, it never blocks on write.
fn write_message(&mut self, message: Message) -> Result<()>
Send a message to stream, if possible.
This function guarantees that the frame is queued regardless of any errors. There is no need to resend the frame. In order to handle WouldBlock or Incomplete, call write_pending() afterwards.
fn send_ping(&mut self, payload: Vec<u8>) -> Result<()>
Send ping.
fn close(&mut self, code: Option<CloseFrame>) -> Result<()>
Close the connection.
This function guarantees that the close frame will be queued. There is no need to call it again, just like write_message().
fn write_pending(&mut self) -> Result<()>
Flush the pending send queue.