pub struct RoomManager { /* private fields */ }Expand description
Manages rooms and their members.
Implementations§
Source§impl RoomManager
impl RoomManager
Sourcepub fn register_connection(&self, connection: Connection)
pub fn register_connection(&self, connection: Connection)
Register a connection.
Sourcepub fn unregister_connection(&self, connection_id: &str)
pub fn unregister_connection(&self, connection_id: &str)
Unregister a connection and remove it from all rooms.
Sourcepub fn get_connection(&self, connection_id: &str) -> Option<Connection>
pub fn get_connection(&self, connection_id: &str) -> Option<Connection>
Get a connection by ID.
Sourcepub fn create_room(&self, room_id: RoomId) -> Arc<Room>
pub fn create_room(&self, room_id: RoomId) -> Arc<Room>
Create a room if it doesn’t exist.
Sourcepub fn delete_room(&self, room_id: &str) -> bool
pub fn delete_room(&self, room_id: &str) -> bool
Delete a room.
Sourcepub fn join_room(
&self,
connection_id: &str,
room_id: &str,
) -> WebSocketResult<()>
pub fn join_room( &self, connection_id: &str, room_id: &str, ) -> WebSocketResult<()>
Join a connection to a room.
Sourcepub fn leave_room(
&self,
connection_id: &str,
room_id: &str,
) -> WebSocketResult<()>
pub fn leave_room( &self, connection_id: &str, room_id: &str, ) -> WebSocketResult<()>
Remove a connection from a room.
Sourcepub fn broadcast_to_room(
&self,
room_id: &str,
message: Message,
) -> WebSocketResult<usize>
pub fn broadcast_to_room( &self, room_id: &str, message: Message, ) -> WebSocketResult<usize>
Broadcast a message to all connections in a room.
Sourcepub fn broadcast_to_room_except(
&self,
room_id: &str,
message: Message,
except_id: &str,
) -> WebSocketResult<usize>
pub fn broadcast_to_room_except( &self, room_id: &str, message: Message, except_id: &str, ) -> WebSocketResult<usize>
Broadcast a message to all connections in a room except one.
Sourcepub fn broadcast_all(&self, message: Message) -> usize
pub fn broadcast_all(&self, message: Message) -> usize
Broadcast a message to all connections.
Sourcepub fn connection_ids(&self) -> Vec<ConnectionId> ⓘ
pub fn connection_ids(&self) -> Vec<ConnectionId> ⓘ
Get all connection IDs.
Sourcepub fn connection_count(&self) -> usize
pub fn connection_count(&self) -> usize
Get the total number of connections.
Sourcepub fn room_count(&self) -> usize
pub fn room_count(&self) -> usize
Get the total number of rooms.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RoomManager
impl !RefUnwindSafe for RoomManager
impl Send for RoomManager
impl Sync for RoomManager
impl Unpin for RoomManager
impl !UnwindSafe for RoomManager
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