import { PeerConnectionOptions } from "./IPeerConnection"; import { VerbosityCode } from "./VerbosityCode"; export type Size = { width: number; height: number; }; export interface IWebSocketMessage { type: "config" | "ping" | "pong" | "answer" | "iceCandidate" | "onVideoInitialized" | "disconnectPlayer" | "playerDisconnected" | "playerCount" | "offer" | "stats" | "streamInfo" | "kick" | "error" | "sessionId" | "queue" | "letter"; /** Format == Date.now() / 1000 * Or in general: as seconds. */ time?: number; /** Player (user) runtime UID */ playerId?: number; /** Name of the requested package to pick a matching streamer. */ packageId?: string; reason?: string; sessionId?: string; candidate?: RTCIceCandidate; peerConnectionOptions?: PeerConnectionOptions; streamInfo?: TStreamInfo; code?: number; /** Can be used to update the access_token. */ token?: string; queue?: Queue; verbosity?: VerbosityCode; } /** * Shallow copy of the IProject.settings.afk Interface. * * AFK stands for 'away from keyboard' and describes a timeout based on activity of the * actual project. All execution of these settings are prone to frontend and therefore no * full security measure for abuse! These settings can be overwritten by shareId, but would * overwrite the settings given through frontend configuration. */ export interface Afk { /** * Time in seconds, after error trigger, the actual disconnection action will take place. */ action: number; /** * Enables / Disables AFK functionality. */ enabled: boolean; /** * Time in seconds, after warn trigger, when a more pushy warning will be triggered. */ error: number; /** * Time in seconds, after last interaction, when the first warning will be triggered. */ warn: number; } export type TStreamInfo = { guid: string; autoPlay: boolean; touchCapable: boolean; resolution: { width: number; height: number; dynamic: boolean; fixed: boolean; }; afk?: Afk; meta?: { friendlyName?: string; creator?: string; copyrightNotice?: string; copyrightVisible?: boolean; ueVersion?: string; mouseLock?: boolean; }; }; export interface ClientConfig extends IWebSocketMessage { type: "config"; peerConnectionOptions: PeerConnectionOptions; } export interface Queue { /** Ticket._id - will not be exposed to frontend. */ _id?: string; /** Position in queue (zero based). */ index?: number; /** Length of the queue. */ queueLength?: number; /** Already waited for. */ waited?: number; /** Based on Average Watch Time, * we calculate an average interval of expected connection closings and based on the amount of concurrent sessions, * we can calculate the estimated time until another slot will be freed up. */ estimatedWaitTime?: number; /** The average time all current sessions. * (How long did it actually take those that waited for them that received a connection to the currently running instances.) */ averageWaitTime?: number; /** Type of all time-values in the que. */ valueType: "milliseconds" | "seconds" | "minutes" | "hours" | "days"; }