pub struct RoomManager { /* private fields */ }Expand description
Manages active rooms and room codes.
Implementations§
Source§impl RoomManager
impl RoomManager
Sourcepub fn with_config(config: RoomConfig) -> Self
pub fn with_config(config: RoomConfig) -> Self
Create a new room manager with custom configuration.
Sourcepub fn create_room(&mut self) -> String
pub fn create_room(&mut self) -> String
Generate a new room code and create the room.
Sourcepub fn room_exists(&self, code: &str) -> bool
pub fn room_exists(&self, code: &str) -> bool
Check if a room code is valid.
Sourcepub fn client_count(&self, code: &str) -> Option<usize>
pub fn client_count(&self, code: &str) -> Option<usize>
Get the number of clients in a room.
Sourcepub fn join_room(
&mut self,
code: &str,
node_id: NodeId,
client_name: Option<String>,
) -> Result<()>
pub fn join_room( &mut self, code: &str, node_id: NodeId, client_name: Option<String>, ) -> Result<()>
Validate a room code and add client.
Sourcepub fn leave_room(&mut self, code: &str, node_id: NodeId) -> bool
pub fn leave_room(&mut self, code: &str, node_id: NodeId) -> bool
Remove a client from their room.
Sourcepub fn update_activity(&mut self, code: &str, node_id: NodeId)
pub fn update_activity(&mut self, code: &str, node_id: NodeId)
Update client activity timestamp.
Sourcepub fn get_room_clients(&self, code: &str) -> Vec<NodeId>
pub fn get_room_clients(&self, code: &str) -> Vec<NodeId>
Get all node IDs in a room.
Sourcepub fn close_room(&mut self, code: &str) -> Vec<NodeId>
pub fn close_room(&mut self, code: &str) -> Vec<NodeId>
Close a room and return all client node IDs.
Sourcepub fn cleanup_expired(&mut self) -> usize
pub fn cleanup_expired(&mut self) -> usize
Clean up expired rooms.
Returns the number of rooms removed.
Sourcepub fn room_count(&self) -> usize
pub fn room_count(&self) -> usize
Get the total number of active 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