export enum ShareMode { Everyone = 'Everyone', Selected = 'Selected', } type Typed = {type: Type; payload: Base}; export interface UIConfig { authMode: 'turn' | 'none' | 'all'; user: string; loggedIn: boolean; version: string; } export interface RoomConfiguration { id?: string; closeOnOwnerLeave?: boolean; mode: RoomMode; username?: string; } export enum RoomMode { Turn = 'turn', Stun = 'stun', Local = 'local', } export interface JoinConfiguration { id: string; password?: string; username?: string; } export interface StringMessage { message: string; } export interface P2PSession { id: string; peer: string; iceServers: ICEServer[]; } export interface ICEServer { urls: string[]; credential: string; username: string; } export interface RoomInfo { id: string; share: ShareMode; mode: RoomMode; users: RoomUser[]; } export interface RoomUser { id: string; name: string; streaming: boolean; you: boolean; owner: boolean; } export interface P2PMessage { sid: string; value: T; } export type Room = Typed; export type Error = Typed; export type HostSession = Typed; export type Name = Typed<{username: string}, 'name'>; export type ClientSession = Typed; export type HostICECandidate = Typed, 'hostice'>; export type ClientICECandidate = Typed, 'clientice'>; export type HostOffer = Typed, 'hostoffer'>; export type ClientAnswer = Typed, 'clientanswer'>; export type StartSharing = Typed<{}, 'share'>; export type RoomCreate = Typed; export type JoinRoom = Typed; export type IncomingMessage = | Room | Error | HostSession | ClientSession | HostICECandidate | ClientICECandidate | HostOffer | ClientAnswer; export type OutgoingMessage = | RoomCreate | Name | JoinRoom | HostICECandidate | ClientICECandidate | HostOffer | ClientAnswer | StartSharing;