pub struct ConnectionManager { /* private fields */ }Expand description
Connection manager
Implementations§
Source§impl ConnectionManager
impl ConnectionManager
Sourcepub fn new(config: ServerConfig) -> Self
pub fn new(config: ServerConfig) -> Self
Create a new connection manager
Sourcepub fn set_cleanup_interval(&mut self, interval: Duration)
pub fn set_cleanup_interval(&mut self, interval: Duration)
Set the cleanup interval
Sourcepub async fn add_connection(&self, connection: Connection) -> u64
pub async fn add_connection(&self, connection: Connection) -> u64
Add a new connection and return its assigned ID.
Sourcepub async fn remove_connection(&self, id: u64, reason: CloseReason)
pub async fn remove_connection(&self, id: u64, reason: CloseReason)
Remove a connection
Sourcepub async fn get_connection(&self, id: u64) -> Option<ConnectionHandle>
pub async fn get_connection(&self, id: u64) -> Option<ConnectionHandle>
Get connection by ID
Sourcepub async fn get_all_connections(&self) -> Vec<ConnectionHandle>
pub async fn get_all_connections(&self) -> Vec<ConnectionHandle>
Get all active connections
Sourcepub async fn connection_count(&self) -> usize
pub async fn connection_count(&self) -> usize
Get current connection count
Sourcepub async fn get_stats(&self) -> ManagerStats
pub async fn get_stats(&self) -> ManagerStats
Get connection manager statistics
Sourcepub async fn start_cleanup_task(&self)
pub async fn start_cleanup_task(&self)
Start the cleanup task
Sourcepub async fn monitor_connections(&self) -> Result<Vec<ConnectionHealth>>
pub async fn monitor_connections(&self) -> Result<Vec<ConnectionHealth>>
Monitor connection health
Sourcepub async fn close_all_connections(&self)
pub async fn close_all_connections(&self)
Close all connections
Sourcepub async fn broadcast_binary_to_all(&self, data: &[u8]) -> Result<()>
pub async fn broadcast_binary_to_all(&self, data: &[u8]) -> Result<()>
Broadcast binary to every active connection.
Sourcepub async fn broadcast_text_to_all(&self, text: &str) -> Result<()>
pub async fn broadcast_text_to_all(&self, text: &str) -> Result<()>
Broadcast text to every active connection.
Trait Implementations§
Source§impl Debug for ConnectionManager
impl Debug for ConnectionManager
Auto Trait Implementations§
impl Freeze for ConnectionManager
impl !RefUnwindSafe for ConnectionManager
impl Send for ConnectionManager
impl Sync for ConnectionManager
impl Unpin for ConnectionManager
impl UnsafeUnpin for ConnectionManager
impl !UnwindSafe for ConnectionManager
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