Struct qws::Sender[][src]

pub struct Sender { /* fields omitted */ }

A representation of the output of the WebSocket connection. Use this to send messages to the other endpoint.

Implementations

impl Sender[src]

pub fn token(&self) -> Token[src]

A Token identifying this sender within the WebSocket.

pub fn connection_id(&self) -> u32[src]

A connection_id identifying this sender within the WebSocket.

pub fn send<M>(&self, msg: M) -> Result<()> where
    M: Into<Message>, 
[src]

Send a message over the connection.

pub fn broadcast<M>(&self, msg: M) -> Result<()> where
    M: Into<Message>, 
[src]

Send a message to the endpoints of all connections.

Be careful with this method. It does not discriminate between client and server connections. If your WebSocket is only functioning as a server, then usage is simple, this method will send a copy of the message to each connected client. However, if you have a WebSocket that is listening for connections and is also connected to another WebSocket, this method will broadcast a copy of the message to all the clients connected and to that WebSocket server.

pub fn close(&self, code: CloseCode) -> Result<()>[src]

Send a close code to the other endpoint.

pub fn close_with_reason<S>(&self, code: CloseCode, reason: S) -> Result<()> where
    S: Into<Cow<'static, str>>, 
[src]

Send a close code and provide a descriptive reason for closing.

pub fn ping(&self, data: Vec<u8>) -> Result<()>[src]

Send a ping to the other endpoint with the given test data.

pub fn pong(&self, data: Vec<u8>) -> Result<()>[src]

Send a pong to the other endpoint responding with the given test data.

pub fn connect(&self, url: Url) -> Result<()>[src]

Queue a new connection on this WebSocket to the specified URL.

pub fn shutdown(&self) -> Result<()>[src]

Request that all connections terminate and that the WebSocket stop running.

pub fn timeout(&self, ms: u64, token: Token) -> Result<()>[src]

Schedule a token to be sent to the WebSocket Handler’s on_timeout method after ms milliseconds

pub fn cancel(&self, timeout: Timeout) -> Result<()>[src]

Queue the cancellation of a previously scheduled timeout.

This method is not guaranteed to prevent the timeout from occurring, because it is possible to call this method after a timeout has already occurred. It is still necessary to handle spurious timeouts.

Trait Implementations

impl Clone for Sender[src]

impl Debug for Sender[src]

impl PartialEq<Sender> for Sender[src]

Auto Trait Implementations

impl !RefUnwindSafe for Sender

impl Send for Sender

impl Sync for Sender

impl Unpin for Sender

impl !UnwindSafe for Sender

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.