File
Blob: worker/src/server/room-state.ts
| 1 | import type { Channel } from '@/shared/contracts/channels.ts'; |
| 2 | import type { Description } from '@/shared/contracts/signaling.ts'; |
| 3 | import type { NowPlaying, Track } from '@/shared/contracts/track.ts'; |
| 4 | |
| 5 | // Primary session resources plus optional allocation receipts retained for cleanup. |
| 6 | export 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. |
| 15 | export 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 | }; |
| 26 | export type Viewer = SessionResources & { |
| 27 | token: string; |
| 28 | generation: string; |
| 29 | seen: number; |
| 30 | closing?: boolean; |
| 31 | }; |
| 32 | export type RoomState = { |
| 33 | publisher?: Publisher; |
| 34 | viewers: Record<string, Viewer>; |
| 35 | controller?: { id: string; until: number }; |
| 36 | }; |