pub struct WebSocketState { /* private fields */ }Expand description
WebSocket connection state manager
Implementations§
Source§impl WebSocketState
impl WebSocketState
pub fn new(config: WebSocketConfig) -> Self
Sourcepub async fn handle_connection(&mut self, websocket: WebSocket) -> Result<()>
pub async fn handle_connection(&mut self, websocket: WebSocket) -> Result<()>
Handle a new WebSocket connection
Sourcepub async fn broadcast_to_all(&self, message: ServerMessage) -> Result<()>
pub async fn broadcast_to_all(&self, message: ServerMessage) -> Result<()>
Broadcast a message to all connected clients
Sourcepub async fn broadcast_to_subscribed(
&self,
message: ServerMessage,
event_type: &str,
) -> Result<()>
pub async fn broadcast_to_subscribed( &self, message: ServerMessage, event_type: &str, ) -> Result<()>
Broadcast a message to subscribed clients only
Sourcepub async fn publish_archive_event(&self, event: ArchiveEvent) -> Result<()>
pub async fn publish_archive_event(&self, event: ArchiveEvent) -> Result<()>
Publish an archive event to all connected clients
Sourcepub async fn ping_all_connections(&self)
pub async fn ping_all_connections(&self)
Send ping to all connections to keep them alive
Sourcepub fn connection_count(&self) -> usize
pub fn connection_count(&self) -> usize
Get current connection count
Sourcepub async fn start_broadcast_listener(
state: Arc<RwLock<WebSocketState>>,
) -> Result<()>
pub async fn start_broadcast_listener( state: Arc<RwLock<WebSocketState>>, ) -> Result<()>
Start the broadcast listener task
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WebSocketState
impl RefUnwindSafe for WebSocketState
impl Send for WebSocketState
impl Sync for WebSocketState
impl Unpin for WebSocketState
impl UnsafeUnpin for WebSocketState
impl UnwindSafe for WebSocketState
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