Struct wasm_sockets::PollingClient
source · [−]pub struct PollingClient {
pub url: String,
pub event_client: EventClient,
pub status: Rc<RefCell<ConnectionStatus>>,
/* private fields */
}Fields
url: StringThe URL this client is connected to
event_client: EventClientThe 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!")?;