<?php

declare(strict_types=1);

namespace Blax\WebRtc\Contracts;

use Blax\WebRtc\Rooms\ConfigRoomRegistry;
use Blax\WebRtc\Rooms\RoomDefinition;
use Blax\WebRtc\Rooms\RoomMode;

/**
 * The set of rooms the backend has DEFINED. The signaling layer consults this to
 * (a) reject joins to unknown rooms and (b) learn each room's transport
 * {@see RoomMode} (p2p vs server-handled). Bind your own to source rooms from a
 * database/model; {@see ConfigRoomRegistry} reads them from config.
 */
interface RoomRegistry
{
    public function has(string $roomId): bool;

    public function get(string $roomId): ?RoomDefinition;

    /** The room's transport, or null when the room is not registered. */
    public function mode(string $roomId): ?RoomMode;

    /** @return array<string,RoomDefinition> keyed by room id */
    public function all(): array;
}
