pub struct WebSocketServer { /* private fields */ }Expand description
WebSocket server for managing real-time connections.
Implementations§
Source§impl WebSocketServer
impl WebSocketServer
Sourcepub fn new(node_id: NodeId, config: WebSocketConfig) -> Self
pub fn new(node_id: NodeId, config: WebSocketConfig) -> Self
Create a new WebSocket server.
Sourcepub fn config(&self) -> &WebSocketConfig
pub fn config(&self) -> &WebSocketConfig
Get the configuration.
Sourcepub async fn register_connection(
&self,
session_id: SessionId,
sender: Sender<WebSocketMessage>,
)
pub async fn register_connection( &self, session_id: SessionId, sender: Sender<WebSocketMessage>, )
Register a new connection.
Sourcepub async fn remove_connection(
&self,
session_id: SessionId,
) -> Option<Vec<SubscriptionId>>
pub async fn remove_connection( &self, session_id: SessionId, ) -> Option<Vec<SubscriptionId>>
Remove a connection.
Sourcepub async fn add_subscription(
&self,
session_id: SessionId,
subscription_id: SubscriptionId,
) -> Result<()>
pub async fn add_subscription( &self, session_id: SessionId, subscription_id: SubscriptionId, ) -> Result<()>
Add a subscription to a connection.
Sourcepub async fn remove_subscription(&self, subscription_id: SubscriptionId)
pub async fn remove_subscription(&self, subscription_id: SubscriptionId)
Remove a subscription from a connection.
Sourcepub async fn send_to_session(
&self,
session_id: SessionId,
message: WebSocketMessage,
) -> Result<()>
pub async fn send_to_session( &self, session_id: SessionId, message: WebSocketMessage, ) -> Result<()>
Send a message to a specific session.
Sourcepub async fn broadcast_delta(
&self,
subscription_id: SubscriptionId,
delta: Delta<Value>,
) -> Result<()>
pub async fn broadcast_delta( &self, subscription_id: SubscriptionId, delta: Delta<Value>, ) -> Result<()>
Send a delta to all sessions subscribed to a subscription.
Sourcepub async fn connection_count(&self) -> usize
pub async fn connection_count(&self) -> usize
Get connection count.
Sourcepub async fn subscription_count(&self) -> usize
pub async fn subscription_count(&self) -> usize
Get subscription count.
Sourcepub async fn cleanup_stale(&self, max_idle: Duration)
pub async fn cleanup_stale(&self, max_idle: Duration)
Cleanup stale connections.
Auto Trait Implementations§
impl Freeze for WebSocketServer
impl !RefUnwindSafe for WebSocketServer
impl Send for WebSocketServer
impl Sync for WebSocketServer
impl Unpin for WebSocketServer
impl !UnwindSafe for WebSocketServer
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