pub struct WebSocketHandle { /* private fields */ }Expand description
Handle to a running WebSocket event stream.
Cheaply cloneable via the inner broadcast sender. Drop all handles
and call shutdown to tear down the background task.
Implementations§
Source§impl WebSocketHandle
impl WebSocketHandle
Sourcepub fn connect(
ws_url: Url,
reconnect: ReconnectConfig,
cancel: CancellationToken,
cookie: Option<String>,
tls_mode: TlsMode,
) -> Result<Self, Error>
pub fn connect( ws_url: Url, reconnect: ReconnectConfig, cancel: CancellationToken, cookie: Option<String>, tls_mode: TlsMode, ) -> Result<Self, Error>
Connect to the controller WebSocket and spawn the reconnection loop.
Returns immediately once the background task is spawned. The first connection attempt happens asynchronously – subscribe to the event receiver to start consuming events.
Sourcepub fn subscribe(&self) -> Receiver<Arc<UnifiEvent>>
pub fn subscribe(&self) -> Receiver<Arc<UnifiEvent>>
Get a new broadcast receiver for the event stream.
Multiple consumers can subscribe concurrently. If a consumer falls
behind, it receives broadcast::error::RecvError::Lagged.
Auto Trait Implementations§
impl Freeze for WebSocketHandle
impl RefUnwindSafe for WebSocketHandle
impl Send for WebSocketHandle
impl Sync for WebSocketHandle
impl Unpin for WebSocketHandle
impl UnsafeUnpin for WebSocketHandle
impl UnwindSafe for WebSocketHandle
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
Mutably borrows from an owned value. Read more