[][src]Struct wasm_sockets::PollingClient

pub struct PollingClient {
    pub url: String,
    pub event_client: EventClient,
    pub status: Rc<RefCell<ConnectionStatus>>,
    // some fields omitted
}

Fields

url: String

The URL this client is connected to

event_client: EventClient

The core EventClient this client is using

status: Rc<RefCell<ConnectionStatus>>

The current connection status

Implementations

impl PollingClient[src]

pub fn new(url: &str) -> Result<Self, WebSocketError>[src]

Create a new PollingClient and connect to a WebSocket URL

Note: An Ok() from this function does not mean the connection has succeeded.

PollingClient::new("wss://echo.websocket.org")?;

pub fn receive(&mut self) -> Vec<Message>[src]

Get all new WebSocket messages that were received since this function was last called

println!("New messages: {:#?}", client.receive());

pub fn status(&self) -> ConnectionStatus[src]

Get the client's current connection status

println!("Current status: {:#?}", client.status());

pub fn send_string(&self, message: &str) -> Result<(), JsValue>[src]

Send a text message to the server

client.send_string("Hello server!")?;

pub fn send_binary(&self, message: Vec<u8>) -> Result<(), JsValue>[src]

Send a binary message to the server

client.send_binary(vec![0x2, 0xF])?;

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.