pub struct ClientBuilder { /* private fields */ }Expand description
Configures and opens an engine.io Client.
build* performs the handshake; Client::connect then starts the session.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new(url: Url) -> Self
pub fn new(url: Url) -> Self
A builder for url. EIO=4 is added to the query; an empty path becomes /engine.io/.
The engine.io parameters (EIO, transport, sid, t, b64) are the client’s own: a
caller’s values for them are dropped, as engine.io-client overrides them.
Sourcepub fn tls_config(self, tls_config: impl Into<TlsConfig>) -> Self
Available on crate features native-tls or rustls only.
pub fn tls_config(self, tls_config: impl Into<TlsConfig>) -> Self
native-tls or rustls only.TLS configuration for https/wss (default: the backend’s default roots).
Sourcepub fn headers(self, headers: HeaderMap) -> Self
pub fn headers(self, headers: HeaderMap) -> Self
HTTP headers for every polling request and the websocket handshake.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Bound for the handshake and the websocket connect (default 20 s).
Sourcepub fn on_close<F, Fut>(self, callback: F) -> Self
pub fn on_close<F, Fut>(self, callback: F) -> Self
Called when the session closes (server close packet or Client::disconnect).
Sourcepub fn on_data<F, Fut>(self, callback: F) -> Self
pub fn on_data<F, Fut>(self, callback: F) -> Self
Called with the data of every message packet.
Sourcepub fn on_open<F, Fut>(self, callback: F) -> Self
pub fn on_open<F, Fut>(self, callback: F) -> Self
Called when Client::connect opens the session.
Sourcepub async fn build(self) -> Result<Client>
pub async fn build(self) -> Result<Client>
Polling handshake, then a websocket upgrade when the server offers one; when the upgrade
fails (a proxy that drops Upgrade:), the session stays on polling, like
engine.io-client.
Sourcepub async fn build_polling(self) -> Result<Client>
pub async fn build_polling(self) -> Result<Client>
Polling only.
Sourcepub async fn build_websocket_with_upgrade(self) -> Result<Client>
pub async fn build_websocket_with_upgrade(self) -> Result<Client>
Polling handshake, then the websocket upgrade; fails when the server offers none.
Sourcepub async fn build_websocket(self) -> Result<Client>
pub async fn build_websocket(self) -> Result<Client>
Websocket only: the handshake runs over the websocket, or (after a polling handshake)
the upgrade probe does. Bounded by the timeout: a blackholed websocket (a proxy that
accepts TCP and drops the upgrade) would otherwise hang and build_with_fallback would
never fall back to polling.
Sourcepub async fn build_with_fallback(self) -> Result<Client>
pub async fn build_with_fallback(self) -> Result<Client>
Polling handshake, then the websocket upgrade within half the timeout; when the upgrade fails (blocked or blackholed websocket) the session stays on polling with the same sid, as engine.io-client does after a failed probe.