pub struct CoreWebsocketClient { /* private fields */ }Expand description
Implements a websocket client.
Implementations§
Source§impl CoreWebsocketClient
impl CoreWebsocketClient
Sourcepub fn initialize_connection<I, C>(
&self,
host: &str,
headers: I,
callbacks: &mut C,
) -> bool
pub fn initialize_connection<I, C>( &self, host: &str, headers: I, callbacks: &mut C, ) -> bool
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
pub fn write(&self, data: &[u8]) -> bool
pub fn disconnect(&self) -> bool
Trait Implementations§
Source§impl ToOwned for CoreWebsocketClient
impl ToOwned for CoreWebsocketClient
Source§type Owned = Ref<CoreWebsocketClient>
type Owned = Ref<CoreWebsocketClient>
Source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
impl Send for CoreWebsocketClient
impl Sync for CoreWebsocketClient
Auto Trait Implementations§
impl Freeze for CoreWebsocketClient
impl RefUnwindSafe for CoreWebsocketClient
impl Unpin for CoreWebsocketClient
impl UnwindSafe for CoreWebsocketClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more