pub struct ConnectionRegistry { /* private fields */ }
Expand description
High-performance connection registry using Arc<RwLock<>> for concurrent access
Implementations§
Source§impl ConnectionRegistry
impl ConnectionRegistry
Sourcepub fn with_channel_manager(channel_manager: Arc<ChannelManager>) -> Self
pub fn with_channel_manager(channel_manager: Arc<ChannelManager>) -> Self
Create a new connection registry with existing channel manager
Sourcepub fn channel_manager(&self) -> &Arc<ChannelManager>
pub fn channel_manager(&self) -> &Arc<ChannelManager>
Get the channel manager
Sourcepub async fn add_connection(
&self,
connection: WebSocketConnection,
) -> ConnectionId
pub async fn add_connection( &self, connection: WebSocketConnection, ) -> ConnectionId
Add a connection to the registry
Sourcepub async fn remove_connection(
&self,
id: ConnectionId,
) -> Option<Arc<WebSocketConnection>>
pub async fn remove_connection( &self, id: ConnectionId, ) -> Option<Arc<WebSocketConnection>>
Remove a connection from the registry
Sourcepub async fn get_connection(
&self,
id: ConnectionId,
) -> Option<Arc<WebSocketConnection>>
pub async fn get_connection( &self, id: ConnectionId, ) -> Option<Arc<WebSocketConnection>>
Get a connection by ID
Sourcepub async fn get_all_connections(&self) -> Vec<Arc<WebSocketConnection>>
pub async fn get_all_connections(&self) -> Vec<Arc<WebSocketConnection>>
Get all active connections
Sourcepub async fn get_connection_ids(&self) -> Vec<ConnectionId>
pub async fn get_connection_ids(&self) -> Vec<ConnectionId>
Get all connection IDs
Sourcepub async fn connection_count(&self) -> usize
pub async fn connection_count(&self) -> usize
Get the number of active connections
Sourcepub async fn send_to_connection(
&self,
id: ConnectionId,
message: WebSocketMessage,
) -> WebSocketResult<()>
pub async fn send_to_connection( &self, id: ConnectionId, message: WebSocketMessage, ) -> WebSocketResult<()>
Send a message to a specific connection
Sourcepub async fn send_text_to_connection<T: Into<String>>(
&self,
id: ConnectionId,
text: T,
) -> WebSocketResult<()>
pub async fn send_text_to_connection<T: Into<String>>( &self, id: ConnectionId, text: T, ) -> WebSocketResult<()>
Send a text message to a specific connection
Sourcepub async fn send_binary_to_connection<T: Into<Vec<u8>>>(
&self,
id: ConnectionId,
data: T,
) -> WebSocketResult<()>
pub async fn send_binary_to_connection<T: Into<Vec<u8>>>( &self, id: ConnectionId, data: T, ) -> WebSocketResult<()>
Send a binary message to a specific connection
Sourcepub async fn broadcast(&self, message: WebSocketMessage) -> BroadcastResult
pub async fn broadcast(&self, message: WebSocketMessage) -> BroadcastResult
Broadcast a message to all active connections
Sourcepub async fn broadcast_text<T: Into<String>>(&self, text: T) -> BroadcastResult
pub async fn broadcast_text<T: Into<String>>(&self, text: T) -> BroadcastResult
Broadcast a text message to all active connections
Sourcepub async fn broadcast_binary<T: Into<Vec<u8>>>(
&self,
data: T,
) -> BroadcastResult
pub async fn broadcast_binary<T: Into<Vec<u8>>>( &self, data: T, ) -> BroadcastResult
Broadcast a binary message to all active connections
Sourcepub async fn send_to_channel(
&self,
channel_id: ChannelId,
sender_id: ConnectionId,
message: WebSocketMessage,
) -> WebSocketResult<BroadcastResult>
pub async fn send_to_channel( &self, channel_id: ChannelId, sender_id: ConnectionId, message: WebSocketMessage, ) -> WebSocketResult<BroadcastResult>
Send a message to a specific channel
Sourcepub async fn send_text_to_channel<T: Into<String>>(
&self,
channel_id: ChannelId,
sender_id: ConnectionId,
text: T,
) -> WebSocketResult<BroadcastResult>
pub async fn send_text_to_channel<T: Into<String>>( &self, channel_id: ChannelId, sender_id: ConnectionId, text: T, ) -> WebSocketResult<BroadcastResult>
Send a text message to a specific channel
Sourcepub async fn send_binary_to_channel<T: Into<Vec<u8>>>(
&self,
channel_id: ChannelId,
sender_id: ConnectionId,
data: T,
) -> WebSocketResult<BroadcastResult>
pub async fn send_binary_to_channel<T: Into<Vec<u8>>>( &self, channel_id: ChannelId, sender_id: ConnectionId, data: T, ) -> WebSocketResult<BroadcastResult>
Send a binary message to a specific channel
Sourcepub async fn close_connection(&self, id: ConnectionId) -> WebSocketResult<()>
pub async fn close_connection(&self, id: ConnectionId) -> WebSocketResult<()>
Close a specific connection
Sourcepub async fn close_all_connections(&self) -> CloseAllResult
pub async fn close_all_connections(&self) -> CloseAllResult
Close all connections
Sourcepub async fn cleanup_inactive_connections(&self) -> usize
pub async fn cleanup_inactive_connections(&self) -> usize
Clean up inactive connections
Sourcepub async fn stats(&self) -> RegistryStats
pub async fn stats(&self) -> RegistryStats
Get registry statistics
Sourcepub async fn add_event_handler<F>(&self, handler: F)
pub async fn add_event_handler<F>(&self, handler: F)
Add an event handler (for future extensibility)