[][src]Struct mio_httpc::WebSocket

pub struct WebSocket { /* fields omitted */ }

WebSocket interface.

WebSocket does not send pings/pongs automatically or close replies.

If received ping, you should send pong back. You can also just send pong which will not invoke a response. You should send ping periodically as you never know if your connection is actually alive without it.

If WSPacket::Close() returned you should call close and then finish. If you want to initiate close, you should call close and wait for WSPacket::Close(), then call finish. That is the standard way of closing ws connections.

Implementations

impl WebSocket[src]

pub fn call(&self) -> &Call[src]

pub fn empty() -> WebSocket[src]

pub fn is_empty(&self) -> bool[src]

pub fn is_active(&self) -> bool[src]

True if websocket is established. False if still initiating or closed.

pub fn sendq_len(&self) -> usize[src]

How many bytes are in send buffer waiting to be sent. Does not take into account any send_bin_inplace packets.

pub fn is_ref(&self, r: CallRef) -> bool[src]

pub fn is_call(&self, cid: &Option<CallRef>) -> bool[src]

For quick comparison with httpc::event response. If cid is none will return false.

pub fn is_opt_call(a: &Option<WebSocket>, b: &Option<CallRef>) -> bool[src]

If using Option in a struct, you can quickly compare callid from httpc::event. If either is none will return false.

pub fn ping(&mut self, body: Option<&[u8]>)[src]

Ping server. Body if present is capped at 125 bytes.

pub fn pong(&mut self, body: Option<&[u8]>)[src]

A reply to ping or not. Both are valid. Body if present is capped at 125 bytes.

pub fn close(&mut self, status: Option<u16>, body: Option<&[u8]>)[src]

A reply to close or initiate close. close must be sent by both parties. Body if present is capped at 125 bytes.

pub fn finish(mut self: Self, htp: &mut Httpc)[src]

Actually close connection. If any other call returns error, you should always call finish afterwards.

pub fn finish_inplace(&mut self, htp: &mut Httpc)[src]

Actually close connection and replace self with an empty websocket.

pub fn send_text(&mut self, fin: bool, pkt: &str)[src]

Send text packet. Data gets copied out into an internal buffer, as it must be masked before sending. No bytes will have been sent after calling this. Actual sending is done by recv_packet or perform.

pub fn send_bin(&mut self, fin: bool, pkt: &[u8])[src]

Send binary packet. Data gets copied out into an internal buffer, as it must be masked before sending. No bytes will have been sent after calling this. Actual sending is done by recv_packet or perform.

pub fn send_bin_inplace(
    &mut self,
    htp: &mut Httpc,
    poll: &Registry,
    fin: bool,
    pkt: &mut [u8]
) -> Result<usize>
[src]

Send websocket packet. It will create a frame for entire size of pkt slice. It is assumed slice always starts at unsent data. If pkt was not sent completely it will remember how many bytes it has leftover for current packet. You must always use previous result to move pkt slice forward.

If starting from the middle, fin is ignored and will be used to start the next packet.

inplace send will mask pkt directly and send it. This is the most efficient method but leaves pkt scrambled.

pub fn recv_packet<'a>(
    &mut self,
    htp: &'a mut Httpc,
    poll: &Registry
) -> Result<WSPacket<'a>>
[src]

You should call this in a loop until you get WSPacket::None.

pub fn perform(&mut self, htp: &mut Httpc, poll: &Registry) -> Result<()>[src]

Perform socket operation.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,