Manages collaboration room lifecycles via DynamicSupervisor.
Provides join-or-create semantics: if a room already exists, returns
its PID; otherwise starts a new PhiaUi.Collab.CollabRoom GenServer
under the PhiaUi.Collab.RoomSupervisor.
This module is stateless — it delegates to the RoomRegistry (a Registry)
for lookups and to the RoomSupervisor (a DynamicSupervisor) for process
management. Both are started by PhiaUi.Collab.Supervisor.
Example
# Ensure the room exists (idempotent)
{:ok, pid} = PhiaUi.Collab.RoomManager.join_or_create_room("doc-123",
callback_module: MyApp.CollabCallbacks,
idle_timeout: :timer.minutes(15)
)
# Later, when user disconnects
PhiaUi.Collab.RoomManager.leave_room("doc-123", "user-42")
Summary
Functions
Get the PID of a running room, or nil if not running.
Join or create a collaboration room.
Leave a room and trigger cleanup if empty.
List all active room IDs.
Count the number of currently active rooms.
Functions
Get the PID of a running room, or nil if not running.
Join or create a collaboration room.
If the room exists, returns {:ok, pid}. Otherwise starts a new
CollabRoom GenServer under the DynamicSupervisor.
Options
:callback_module— module implementingPhiaUi.Collab.CollabRoombehaviour:idle_timeout— milliseconds before an empty room shuts down (default 30 min)
Returns
{:ok, pid}— the room process PID{:error, reason}— if the room could not be started
Leave a room and trigger cleanup if empty.
Safe to call even if the room is not running — returns :ok in all cases.
@spec list_rooms() :: [String.t()]
List all active room IDs.
Returns a list of room ID strings for all currently running CollabRoom processes.
@spec room_count() :: non_neg_integer()
Count the number of currently active rooms.