Class RoomManager

java.lang.Object
net.targetr.rc.RoomManager

public class RoomManager extends Object
Maintains a map of active rooms.
Author:
Dr Michael Gardiner
  • Method Details

    • get

      public static RoomManager get()
      Retrieves the singleton RoomManager instance.
      Returns:
      the room manager
    • attachClient

      public RoomManager.Attachment attachClient(ClientRequest req)
      Looks up or creates a room and attaches a client before it can be evicted.
      Parameters:
      req - the incoming client request
      Returns:
      the registered room and its attached client, or null if the room is full
    • findRoom

      public Room findRoom(String roomId)
      Looks up a room without creating it or extending its empty-room lifetime.
      Parameters:
      roomId - the requested room
      Returns:
      the existing room, or null if it does not exist
    • getRoom

      public Room getRoom(ClientRequest req)
      Retrieves an existing room given a client request.
      Parameters:
      req - the incoming client request
      Returns:
      the associated Room instance
    • getRoom

      public Room getRoom(String roomId)
      Retrieves a room, or creates a new one if it does not exist. Use attachClient(ClientRequest) to join a managed room safely.
      Parameters:
      roomId - the requested room
      Returns:
      the associated Room instance
    • getRoomCount

      public int getRoomCount()
      Gets the total number of active rooms.
      Returns:
      the room count
    • getLiveClientCount

      public int getLiveClientCount()
      Gets the total aggregate number of live clients in all rooms.
      Returns:
      the total client count
    • getState

      public Map<String,Object> getState()
      Aggregates state representations from all active rooms.
      Returns:
      a map organizing room states by their roomIds.
    • closeAll

      public void closeAll()
      Forcefully closes all network connections currently established to all rooms. Designed to be called during application shutdown.