import { AnimojiVersion } from '@vkontakte/calls-vmoji'; import { TransportTopology } from '../classes/transport/Transport'; import ChatRoomEventType from '../enums/ChatRoomEventType'; import ConversationFeature from '../enums/ConversationFeature'; import ConversationOption from '../enums/ConversationOption'; import FatalError from '../enums/FatalError'; import HangupType from '../enums/HangupType'; import MediaOption from '../enums/MediaOption'; import MuteState from '../enums/MuteState'; import ParticipantState from '../enums/ParticipantState'; import RoomsEventType from '../enums/RoomsEventType'; import SignalingCommandType from '../enums/SignalingCommandType'; import UserRole from '../enums/UserRole'; import UserType from '../enums/UserType'; import { AsrInfo } from './Asr'; import { IFeaturesPerRole } from './ConversationFeature'; import { IFeedback } from './Feedback'; import MediaModifiers from './MediaModifiers'; import MediaSettings from './MediaSettings'; import { ISharedMovieInfo, ISharedMovieState, ISharedMovieStoppedInfo } from './MovieShare'; import MuteStates from './MuteStates'; import { CompositeUserId, OkUserId, ParticipantId, ParticipantListMarker as ParticipantParticipantListMarker, ParticipantListMarkers, ParticipantListType as ParticipantParticipantListType } from './Participant'; import { MediaType, ParticipantStreamDescription } from './ParticipantStreamDescription'; import { IRoomId } from './Room'; import VideoSettings from './VideoSettings'; import { ChatRoom } from './WaitingHall'; type SignalingMessage = Record; export type RecordInfo = { initiator: ParticipantId; recordMovieId: number; recordStartTime: number; recordType: 'STREAM' | 'RECORD'; recordExternalMovieId?: string; recordExternalOwnerId?: string; }; export interface SignalingResponse extends SignalingMessage { response?: SignalingCommandType; error?: string; reason?: HangupType | FatalError; sequence?: number; type: 'response' | 'error' | 'timeout'; } export interface SignalingSuccessResponse extends SignalingResponse { response: SignalingCommandType; sequence: number; } export interface GetRoomsSignalingResponse extends SignalingSuccessResponse { rooms: { rooms: SignalingMessage.Room[]; roomId?: number; }; } export interface GetParticipantsSignalingResponse extends SignalingSuccessResponse { participants: SignalingMessage.Participant[]; } declare namespace SignalingMessage { export interface ExternalId { type: 'UNKNOWN' | 'VK' | 'ANONYM'; id: string; } export interface PeerId { id: number; type?: string; } export type ParticipantListType = ParticipantParticipantListType; export type ParticipantListMarker = ParticipantParticipantListMarker; export type ParticipantUpdateInfo = { participantStreamDescription: ParticipantStreamDescription | null; streamId: string; rtpTimestamp: number | null; sequenceNumber: number; fastScreenShare: boolean; suspend?: boolean; }; export interface Participant { id: OkUserId; idType?: UserType; decorativeUserId?: CompositeUserId; decorativeExternalUserId?: ExternalId; deviceIdx?: number; externalId?: ExternalId; state: ParticipantState; responders?: OkUserId[]; responderTypes?: UserType[]; responderDeviceIdxs?: number[]; permissions?: string[]; mediaSettings: Partial; participantState?: { state: Record; stateUpdateTs: Record; }; roles?: UserRole[]; peerId?: PeerId; restricted?: boolean; muteStates?: MuteStates; unmuteOptions?: MediaOption[]; markers?: ParticipantListMarkers; observedIds?: CompositeUserId[]; movieShareInfos?: ISharedMovieInfo[]; } export interface ParticipantListChunk extends Notification { participants: (Participant & Required>)[]; countBefore: number; countAfter: number; markerFound: boolean; } export interface WaitingParticipantId { addedTs: number; id: CompositeUserId; } export interface WaitingParticipant { id: WaitingParticipantId; externalId?: ExternalId; } export interface RoomUrlSharingInfo { sharedUrl: string; initiatorId: CompositeUserId; } export interface Conversation { id: string; state: string; topology: TransportTopology; participants: Participant[]; participantsLimit: number; acceptTime: number | null; features: ConversationFeature[]; multichatId: string | null; tamtamMultichatId: string | null; recordInfo?: RecordInfo; featuresPerRole?: IFeaturesPerRole | null; pinnedParticipantId: ParticipantId | null; options: ConversationOption[]; muteStates?: MuteStates; asrInfo?: AsrInfo; urlSharingInfo?: RoomUrlSharingInfo; joinLink?: string; } export interface Room { active?: boolean; addParticipantIds?: CompositeUserId[]; asrInfo?: AsrInfo; countdownSec?: number; id?: number; muteStates?: MuteStates; name?: string; participantCount?: number; participantIds?: CompositeUserId[]; participants?: ParticipantListChunk; pinnedParticipantId?: CompositeUserId; recordInfo?: RecordInfo; removeParticipantIds?: CompositeUserId[]; timeoutMs?: number; urlSharingInfo?: RoomUrlSharingInfo; } interface Notification extends SignalingMessage { type?: string; notification?: string; stamp?: number; } export interface TransmittedData extends Notification { participantId: OkUserId; participantType: UserType; deviceIdx?: number; peerId: PeerId; data: { candidate?: RTCIceCandidateInit; sdp?: Required; animojiVersion?: AnimojiVersion; }; } export interface RegisteredPeer extends Notification { participantId: OkUserId; participantType: UserType; deviceIdx?: number; peerId: PeerId; platform: string; clientType: string; } export interface AcceptedCall extends Notification { participantId: OkUserId; participantType: UserType; deviceIdx?: number; peerId: PeerId; mediaSettings: Partial; capabilities?: string; } export interface Hungup extends Notification { participantId: OkUserId; participantType: UserType; deviceIdx?: number; peerId: PeerId; reason: HangupType; markers?: ParticipantListMarkers; } export interface ClosedConversation extends Notification { reason: HangupType; } export interface MediaSettingsChanged extends Notification { participantId: OkUserId; participantType: UserType; deviceIdx?: number; peerId: PeerId; mediaSettings: Partial; markers?: ParticipantListMarkers; } export interface ParticipantStateChanged extends Notification { participantId: OkUserId; participantType: UserType; deviceIdx?: number; peerId: PeerId; mediaSettings: Partial; participantState: { state: Record; stateUpdateTs: Record; }; markers?: ParticipantListMarkers; } export interface ParticipantsStateChanged extends Notification { participants: { id: CompositeUserId; participantState?: { state: Record; stateUpdateTs: Record; }; markers?: ParticipantListMarkers; }[]; roomId?: IRoomId; } export interface RolesChanged extends Notification { adminId: ParticipantId; participantId: ParticipantId; roles?: UserRole[]; } export interface MuteParticipant extends Notification { adminId?: ParticipantId; participantId?: ParticipantId; muteStates: MuteStates; unmuteOptions?: MediaOption[]; mediaOptions: MediaOption[]; requestedMedia?: MediaOption[]; stateUpdated?: boolean; unmute?: boolean; muteAll?: boolean; roomId?: number | null; } export interface PinParticipant extends Notification { participantId: ParticipantId; unpin?: boolean; roomId?: number; } export interface ParticipantAdded extends Notification { callerId: OkUserId; participantId: OkUserId; participant: Participant; } export interface ParticipantJoined extends Notification { participantId: OkUserId; participant: Participant; mediaSettings: Partial; } export interface ProducerUpdated extends Notification { description: string; sessionId: string; } export interface ConsumerAnswered extends Notification { description: string; } export interface TopologyChanged extends Notification { topology: TransportTopology; offerTo: OkUserId[]; offerToTypes: UserType[]; offerToDeviceIdxs: number[]; } export interface RateCallData extends Notification { maxRateForQuestion: number; possibleAnswers: Record; } export interface FeatureSetChanged extends Notification { features: ConversationFeature[]; } export interface MultipartyChatCreated extends Notification { chatId: string; } export interface ForceMediaSettingsChange extends Notification { mediaSettings: Partial; reason: string; } export interface RecordStarted extends Notification { recordInfo: RecordInfo; } export interface RecordStopped extends Notification { /** кто остановил запись или если в комнатах, то это админ */ participant: ParticipantId; recordMovieId: number; } export interface ReallocCon extends Notification { idType: UserType; target: TransportTopology; } export interface ChatMessage extends Notification { participantId: OkUserId; participantType: UserType; deviceIdx?: number; direct: boolean; message: string; } export interface JoinLinkChanged extends Notification { joinLink: string | null; } export interface SettingsUpdate extends Notification { camera: VideoSettings; screenSharing: VideoSettings; fastScreenSharing: VideoSettings; settings: Record; } export interface StalledActivity extends Notification { stalledParticipants: ParticipantId[]; } export interface AudioActivity extends Notification { activeParticipants: ParticipantId[]; } export interface SpeakerChanged extends Notification { speaker: ParticipantId; } export interface OptionsChanged extends Notification { options: ConversationOption[]; } export interface NetworkStatus extends Notification { statuses: Record; } export interface PromotionApproved extends Notification { adminId: ParticipantId; } export interface PromoteParticipant extends Notification { demote: boolean; mediaModifiers: MediaModifiers; conversation: Conversation; participants?: ParticipantListChunk; muteState?: MuteState; muteOptions?: MediaOption[]; } export interface ChatRoomUpdated extends Notification { eventType: ChatRoomEventType; totalCount: ChatRoom['totalCount']; firstParticipants?: ChatRoom['firstParticipants']; addedParticipantIds?: ParticipantId[]; removedParticipantIds?: ParticipantId[]; feedback?: ChatRoom['feedback']; } export interface VideoQualityUpdate extends Notification { quality: { maxBitrate: number; maxDimension: number; }; mediaType?: MediaType; } export interface CustomData extends Notification { participantId: OkUserId; participantType: UserType; deviceIdx?: number; data: Record; } export interface SwitchMicro extends Notification { mute: boolean; } export interface Connection extends Notification { endpoint: string; conversation: Conversation; isConcurrent: boolean; peerId: PeerId; mediaModifiers: MediaModifiers; participants?: ParticipantListChunk; chatRoom?: ChatRoom; rooms?: { rooms: Room[]; roomId?: number; }; muteState?: MuteState; muteOptions?: MediaOption[]; } export interface Feedback extends Notification { feedback: IFeedback[]; roomId?: number; } export interface SharedMovieState extends Notification { data: ISharedMovieState[]; } export interface SharedMovieInfo extends Notification { movieShareInfo: ISharedMovieInfo; roomId?: IRoomId; } export interface SharedMovieStoppedInfo extends Notification, ISharedMovieStoppedInfo { roomId?: IRoomId; } export interface UrlSharingInfo extends Notification { initiatorId: CompositeUserId; sharedUrl?: string; roomId?: IRoomId; } export interface RoomsUpdated extends Notification { updates: Partial>; } export interface RoomUpdated extends Notification { events: RoomsEventType[]; room?: Room; roomId: number; deactivate?: boolean; muteStates?: MuteStates; recordInfo?: RecordInfo; asrInfo?: AsrInfo; countdownSec?: number; timeoutMs?: number; } export interface RoomParticipantsUpdated extends Notification { roomId?: number; participantCount: number; addedParticipantIds?: CompositeUserId[]; addedParticipants?: Participant[]; removedParticipantMarkers?: ParticipantListMarkers[]; } export interface GetRooms extends Notification { rooms: { rooms: Room[]; roomId?: number; }; } export interface FeaturesPerRoleChanged extends Notification { featuresPerRole?: IFeaturesPerRole | null; } export interface ParticipantAnimojiChanged extends Notification { participantId: ParticipantId; } export interface AsrStartNotification extends Notification { asrInfo: AsrInfo; roomId?: number; } export interface AsrStopNotification extends Notification { roomId?: number; } export interface ParticipantSourcesUpdateNotification extends Notification { participantUpdateInfos: ParticipantUpdateInfo[]; } export interface DecorativeParticipantIdChanged extends Notification { participantId: CompositeUserId; decorativeParticipantId?: CompositeUserId; decorativeExternalParticipantId?: ExternalId; } export interface VideoSuspendSuggest extends Notification { bandwidth: number; } export {}; } export default SignalingMessage;