Skip to main content

connect

Function connect 

Source
pub async fn connect<S: AsRef<str>>(
    uri: S,
) -> Result<(Client, EventStream), ConnectError>
Available on crate feature websocket only.
Expand description

Connects to a simplex-chat WebSocket server, returning a Client and an EventStream that handle serialization/deserialization of commands and events.

let (client, mut events) = simploxide_client::ws::connect("ws://127.0.0.1:5225").await?;

let current_user = client.api_show_active_user().await?;
println!("{current_user:#?}");

while let Some(ev) = events.try_next().await? {
    // Process events...
}