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

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§

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://ws.ifelse.io")?;

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

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

Get the client’s current connection status

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

Send a text message to the server

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

Send a binary message to the server

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

Close the connection

client.close()?;

Close the connection with a custom close code and, optionally, a reason string

The reason string must be at most 123 bytes long.

client.close_with(1001, Some("going away"))?;

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.