Skip to content
File

Blob: worker/src/server/room-state.ts

typescript37 lines
1import type { Channel } from '@/shared/contracts/channels.ts';
2import type { Description } from '@/shared/contracts/signaling.ts';
3import type { NowPlaying, Track } from '@/shared/contracts/track.ts';
4 
5// Primary session resources plus optional allocation receipts retained for cleanup.
6export type SessionResources = {
7 sessionId: string;
8 channels: Channel[];
9 mid?: string;
10 pendingChannels?: number[];
11 pendingMids?: string[];
12};
13 
14// Keep additions optional so stored rooms from earlier Worker versions still load.
15export type Publisher = SessionResources & {
16 generation: string;
17 ready: boolean;
18 seen: number;
19 bootId?: string;
20 offerHash?: string;
21 answer?: Description;
22 track?: Track;
23 nowPlaying?: NowPlaying;
24 initialNowPlaying?: NowPlaying;
25};
26export type Viewer = SessionResources & {
27 token: string;
28 generation: string;
29 seen: number;
30 closing?: boolean;
31};
32export type RoomState = {
33 publisher?: Publisher;
34 viewers: Record<string, Viewer>;
35 controller?: { id: string; until: number };
36};