[][src]Function showdown::connect_to_url

pub async fn connect_to_url<'_>(url: &'_ Url) -> Result<(Sender, Receiver)>

Connects to an URL.

This URL is provided by fetch_server_url function.

Examples

use futures::prelude::*;
use showdown::{connect_to_url, fetch_server_url, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let url = fetch_server_url("smogtours").await?;
    assert_eq!(url.as_str(), "ws://sim3.psim.us:8002/showdown/websocket");
    connect_to_url(&url).await?;
    Ok(())
}