socketio-rs 0.1.8

An implementation of a socketio written in rust.
Documentation
pub(crate) mod ack;
pub(crate) mod callback;
#[cfg(feature = "client")]
pub(crate) mod client;
pub(crate) mod error;
pub(crate) mod event;
pub(crate) mod packet;
pub(crate) mod payload;
#[cfg(feature = "server")]
pub(crate) mod server;

mod socket;

pub use ack::AckId;
#[cfg(feature = "client")]
pub use client::{Client, ClientBuilder, Socket, TransportType};
pub use error::{Error, Result};
pub use event::Event;
pub use packet::{Packet, PacketType};
pub use payload::Payload;
#[cfg(feature = "server")]
pub use server::{Client as ServerSocket, Server, ServerBuilder};

#[cfg(feature = "server")]
pub(crate) type NameSpace = String;

#[cfg(test)]
pub(crate) mod test {
    use url::Url;

    /// The socket.io server for testing runs on port 4200
    const SERVER_URL: &str = "http://localhost:4200";

    pub(crate) fn socket_io_server() -> Url {
        let url = std::env::var("SOCKET_IO_SERVER").unwrap_or_else(|_| SERVER_URL.to_owned());
        let mut url = Url::parse(&url).unwrap();

        if url.path() == "/" {
            url.set_path("/socket.io/");
        }

        url
    }

    /// The rust socket.io server for testing runs on port 4209
    const RUST_SERVER_URL: &str = "http://localhost:4209";

    pub(crate) fn rust_socket_io_server() -> Url {
        let url =
            std::env::var("SOCKET_IO_RUST_SERVER").unwrap_or_else(|_| RUST_SERVER_URL.to_owned());
        let mut url = Url::parse(&url).unwrap();

        if url.path() == "/" {
            url.set_path("/socket.io/");
        }

        url
    }
}