pub struct CoreWebsocketClient { /* private fields */ }
Expand description
Implements a websocket client.
Implementations§
source§impl CoreWebsocketClient
impl CoreWebsocketClient
sourcepub fn initialize_connection<I, K, V, C>(
&self,
host: &str,
headers: I,
callbacks: &mut C,
) -> boolwhere
I: IntoIterator<Item = (K, V)>,
K: BnStrCompatible,
V: BnStrCompatible,
C: WebsocketClientCallback,
pub fn initialize_connection<I, K, V, C>(
&self,
host: &str,
headers: I,
callbacks: &mut C,
) -> boolwhere
I: IntoIterator<Item = (K, V)>,
K: BnStrCompatible,
V: BnStrCompatible,
C: WebsocketClientCallback,
Initializes the web socket connection.
Connect to a given url, asynchronously. The connection will be run in a separate thread managed by the websocket provider.
Callbacks will be called on the thread of the connection, so be sure to ExecuteOnMainThread any long-running or gui operations in the callbacks.
If the connection succeeds, WebsocketClientCallback::connected will be called. On normal termination, WebsocketClientCallback::disconnected will be called.
If the connection succeeds, but later fails, WebsocketClientCallback::disconnected will not be called, and WebsocketClientCallback::error will be called instead.
If the connection fails, neither WebsocketClientCallback::connected nor WebsocketClientCallback::disconnected will be called, and WebsocketClientCallback::error will be called instead.
If WebsocketClientCallback::connected or WebsocketClientCallback::read return false, the connection will be aborted.
host
- Full url with scheme, domain, optionally port, and pathheaders
- HTTP header keys and valuescallback
- Callbacks for various websocket events
sourcepub fn notify_connected(&self) -> bool
pub fn notify_connected(&self) -> bool
Call the connect callback function, forward the callback returned value
sourcepub fn notify_disconnected(&self)
pub fn notify_disconnected(&self)
Notify the callback function of a disconnect,
NOTE: This does not actually disconnect, use the Self::disconnect function for that.
sourcepub fn notify_error(&self, msg: &str)
pub fn notify_error(&self, msg: &str)
Call the error callback function
sourcepub fn notify_read(&self, data: &[u8]) -> bool
pub fn notify_read(&self, data: &[u8]) -> bool
Call the read callback function, forward the callback returned value