pub struct WebSocketManager { /* private fields */ }Expand description
Manages connected WebSocket clients for all active subscriptions.
Implementations§
Source§impl WebSocketManager
impl WebSocketManager
Sourcepub fn register_client(
&self,
tenant_id: &str,
subscription_id: &str,
) -> (String, UnboundedReceiver<Value>)
pub fn register_client( &self, tenant_id: &str, subscription_id: &str, ) -> (String, UnboundedReceiver<Value>)
Registers a new WebSocket client for a subscription.
Returns (client_id, receiver). The caller (WebSocket handler) reads
notifications from the receiver and forwards them over the socket.
Sourcepub fn remove_client(
&self,
tenant_id: &str,
subscription_id: &str,
client_id: &str,
)
pub fn remove_client( &self, tenant_id: &str, subscription_id: &str, client_id: &str, )
Removes a specific client by ID (called on disconnect).
Sourcepub fn send_to_subscription(
&self,
tenant_id: &str,
subscription_id: &str,
notification: &Value,
) -> usize
pub fn send_to_subscription( &self, tenant_id: &str, subscription_id: &str, notification: &Value, ) -> usize
Broadcasts a notification to all connected clients for a subscription.
Automatically prunes disconnected clients (closed channels). Returns the number of clients that received the message.
Sourcepub fn client_count(&self, tenant_id: &str, subscription_id: &str) -> usize
pub fn client_count(&self, tenant_id: &str, subscription_id: &str) -> usize
Returns the number of connected clients for a subscription.
Sourcepub fn remove_all_clients(&self, tenant_id: &str, subscription_id: &str)
pub fn remove_all_clients(&self, tenant_id: &str, subscription_id: &str)
Removes all clients for a subscription (called on deregistration).
Dropping the senders causes receivers to return None, which
triggers graceful close in the WebSocket handlers.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for WebSocketManager
impl Freeze for WebSocketManager
impl Send for WebSocketManager
impl Sync for WebSocketManager
impl Unpin for WebSocketManager
impl UnsafeUnpin for WebSocketManager
impl UnwindSafe for WebSocketManager
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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