diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..d3370c9 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,1201 @@ +declare module "react-native-voximplant" { + import React from "react"; + import { ViewProps } from "react-native"; + + namespace Voximplant { + export function getInstance(clientConfig?: ClientConfig): Client; + export function getMessenger(): Messaging.Messenger; + + export class Client { + public setLoggerCallback( + callback: (level: LogLevel, message: string) => void, + ): void; + + public on( + event: K, + handler: (event: ClientEventHandlers[K]) => void, + ): void; + + public off( + event: K, + handler?: (event: ClientEventHandlers[K]) => void, + ): void; + + public connect( + options?: ConnectOptions, + ): Promise< + | ClientEventHandlers["ConnectionEstablished"] + | ClientEventHandlers["ConnectionFailed"] + >; + + public disconnect(): Promise; + + public getClientState(): Promise; + + public login( + username: string, + password: string, + ): Promise; + + public loginWithOneTimeKey( + username: string, + hash: string, + ): Promise; + + public loginWithToken( + username: string, + token: string, + ): Promise; + + public requestOneTimeLoginKey( + username: string, + ): Promise; + + public tokenRefresh( + username: string, + refreshToken: string, + ): Promise; + + public registerPushNotificationsToken(token: string): void; + + public registerIMPushNotificationsTokenIOS(token: string): void; + + public unregisterPushNotificationsToken(token: string): void; + + public unregisterIMPushNotificationsTokenIOS(token: string): void; + + public handlePushNotification(notification: object): void; + + public call(number: string, callSettings?: CallSettings): Promise; + + public callConference( + number: string, + callSettings?: CallSettings, + ): Promise; + } + + class QualitySubscriber { + public on( + event: K, + handler: (event: QualityEventHandlers[K]) => void, + ): void; + + public off( + event: K, + handler?: (event: QualityEventHandlers[K]) => void, + ): void; + } + export class Call { + public callId: string; + public localVideoStreams: VideoStream[]; + public callKitUUID: string | null; + public qualityIssues: QualitySubscriber; + + public on( + event: K, + handler: (event: CallEventHandlers[K]) => void, + ): void; + + public off( + event: K, + handler?: (event: CallEventHandlers[K]) => void, + ): void; + + public answer(callSettings?: CallSettings): void; + + public decline(headers?: object): void; + + public reject(headers?: object): void; + + public sendAudio(enable: boolean): void; + + public sendTone(key: string): void; + + public sendVideo( + enable: boolean, + ): Promise; + + public hold( + enable: boolean, + ): Promise; + + public receiveVideo(): Promise< + void | CallEventHandlers["CallOperationFailed"] + >; + + public hangup(headers?: object): void; + + public sendMessage(message: string): void; + + public sendInfo( + mimeType: string, + body: string, + extraHeaders?: object, + ): void; + + public getEndpoints(): Endpoint[]; + + public getDuration(): Promise; + + public currentQualityIssues(): Promise< + { [key in QualityEvents]?: QualityIssueLevel } | CallError + >; + } + + export enum CallEvents { + Connected = "Connected", + Disconnected = "Disconnected", + EndpointAdded = "EndpointAdded", + Failed = "Failed", + ICECompleted = "ICECompleted", + ICETimeout = "ICETimeout", + InfoReceived = "InfoReceived", + LocalVideoStreamAdded = "LocalVideoStreamAdded", + LocalVideoStreamRemoved = "LocalVideoStreamRemoved", + MessageReceived = "MessageReceived", + ProgressToneStart = "ProgressToneStart", + ProgressToneStop = "ProgressToneStop", + CallReconnecting = "CallReconnecting", + CallReconnected = "CallReconnected", + } + export interface CallEventHandlers { + [CallEvents.Connected]: EventHandlers.CallEventWithHeaders; + [CallEvents.Disconnected]: EventHandlers.Disconnected; + [CallEvents.EndpointAdded]: EventHandlers.EndpointAdded; + [CallEvents.Failed]: EventHandlers.Failed; + [CallEvents.ICECompleted]: EventHandlers.CallEvent; + [CallEvents.ICETimeout]: EventHandlers.CallEvent; + [CallEvents.InfoReceived]: EventHandlers.InfoReceived; + [CallEvents.LocalVideoStreamAdded]: EventHandlers.LocalVideoStreamAdded; + [CallEvents.LocalVideoStreamRemoved]: EventHandlers.LocalVideoStreamRemoved; + [CallEvents.MessageReceived]: EventHandlers.MessageReceived; + [CallEvents.ProgressToneStart]: EventHandlers.CallEventWithHeaders; + [CallEvents.ProgressToneStop]: EventHandlers.CallEvent; + [CallEvents.CallReconnecting]: EventHandlers.CallEvent; + [CallEvents.CallReconnected]: EventHandlers.CallEvent; + CallOperationFailed: EventHandlers.CallOperationFailed; + } + + export class Endpoint { + public id: string; + public displayName: string; + public sipUri: string; + public userName: string; + public videoStreams: VideoStream[]; + + public on( + eventType: K, + handler: (event: EndpointEventHandlers[K]) => void, + ): void; + + public off( + eventType?: K, + handler?: (event: EndpointEventHandlers[K]) => void, + ): void; + + public requestVideoSize( + streamId: string, + width: number, + height: number, + ): Promise; + + public startReceiving(streamId: string): Promise; + + public stopReceiving(streamId: string): Promise; + } + + export class VideoStream { + public id: string; + public isLocal: boolean; + public type: VideoStreamType; + } + + export class VideoView extends React.Component {} + export interface VideoViewProps extends ViewProps { + scaleType?: RenderScaleType; + videoStreamId?: string; + showOnTop?: boolean; + } + + export enum EndpointEvents { + InfoUpdated = "InfoUpdated", + RemoteVideoStreamAdded = "RemoteVideoStreamAdded", + RemoteVideoStreamRemoved = "RemoteVideoStreamRemoved", + Removed = "Removed", + VoiceActivityStarted = "VoiceActivityStarted", + VoiceActivityStopped = "VoiceActivityStopped", + StartReceivingVideoStream = "StartReceivingVideoStream", + StopReceivingVideoStream = "StopReceivingVideoStream", + } + export interface EndpointEventHandlers { + [EndpointEvents.InfoUpdated]: EventHandlers.InfoUpdated; + [EndpointEvents.RemoteVideoStreamAdded]: EventHandlers.RemoteVideoStreamAdded; + [EndpointEvents.RemoteVideoStreamRemoved]: EventHandlers.RemoteVideoStreamRemoved; + [EndpointEvents.Removed]: EventHandlers.Removed; + [EndpointEvents.VoiceActivityStarted]: EventHandlers.EndpointDefaultEvent; + [EndpointEvents.VoiceActivityStopped]: EventHandlers.EndpointDefaultEvent; + [EndpointEvents.StartReceivingVideoStream]: EventHandlers.StartReceivingVideoStream; + [EndpointEvents.StopReceivingVideoStream]: EventHandlers.StopReceivingVideoStream; + } + + export enum ClientEvents { + ConnectionEstablished = "ConnectionEstablished", + ConnectionFailed = "ConnectionFailed", + ConnectionClosed = "ConnectionClosed", + AuthResult = "AuthResult", + RefreshTokenResult = "RefreshTokenResult", + IncomingCall = "IncomingCall", + Reconnecting = "Reconnecting", + Reconnected = "Reconnected", + } + export interface ClientEventHandlers { + [ClientEvents.ConnectionEstablished]: EventHandlers.ConnectionEstablished; + [ClientEvents.ConnectionFailed]: EventHandlers.ConnectionFailed; + [ClientEvents.ConnectionClosed]: EventHandlers.ConnectionClosed; + [ClientEvents.AuthResult]: EventHandlers.AuthResult; + [ClientEvents.RefreshTokenResult]: EventHandlers.AuthTokenResult; + [ClientEvents.IncomingCall]: EventHandlers.IncomingCall; + [ClientEvents.Reconnecting]: EventHandlers.Reconnecting; + [ClientEvents.Reconnected]: EventHandlers.Reconnected; + } + + export enum ClientState { + DISCONNECTED = "disconnected", + CONNECTING = "connecting", + CONNECTED = "connected", + LOGGING_IN = "logging_in", + LOGGED_IN = "logged_in", + RECONNECTING = "reconnecting", + } + + export enum RenderScaleType { + SCALE_FILL = "fill", + SCALE_FIT = "fit", + } + + export enum CallError { + ALREADY_IN_THIS_STATE = "ALREADY_IN_THIS_STATE", + FUNCTIONALITY_IS_DISABLED = "FUNCTIONALITY_IS_DISABLED", + INCORRECT_OPERATION = "INCORRECT_OPERATION", + INTERNAL_ERROR = "INTERNAL_ERROR", + MEDIA_IS_ON_HOLD = "MEDIA_IS_ON_HOLD", + MISSING_PERMISSION = "MISSING_PERMISSION", + NOT_LOGGED_IN = "NOT_LOGGED_IN", + REJECTED = "REJECTED", + TIMEOUT = "TIMEOUT", + RECONNECTING = "RECONNECTING", + } + + export enum LogLevel { + ERROR = "error", + WARNING = "warning", + INFO = "info", + DEBUG = "debug", + VERBOSE = "verbose", + } + + export enum VideoCodec { + VP8 = "VP8", + H264 = "H264", + AUTO = "AUTO", + } + + export enum RequestAudioFocusMode { + REQUEST_ON_CALL_START = "REQUEST_ON_CALL_START", + REQUEST_ON_CALL_CONNECTED = "REQUEST_ON_CALL_CONNECTED", + } + + export enum VideoStreamType { + VIDEO = "Video", + SCREEN_SHARING = "ScreenSharing", + } + + export enum VideoStreamReceiveStopReason { + AUTOMATIC = "Automatic", + MANUAL = "Manual", + } + + export enum QualityEvents { + PacketLoss = "PacketLoss", + CodecMismatch = "CodecMismatch", + LocalVideoDegradation = "LocalVideoDegradation", + IceDisconnected = "IceDisconnected", + HighMediaLatency = "HighMediaLatency", + NoAudioSignal = "NoAudioSignal", + NoAudioReceive = "NoAudioReceive", + NoVideoReceive = "NoVideoReceive", + } + export interface QualityEventHandlers { + [QualityEvents.PacketLoss]: EventHandlers.PacketLossEvent; + [QualityEvents.CodecMismatch]: EventHandlers.CodecMismatchEvent; + [QualityEvents.LocalVideoDegradation]: EventHandlers.LocalVideoDegradationEvent; + [QualityEvents.IceDisconnected]: EventHandlers.IceDisconnectedEvent; + [QualityEvents.HighMediaLatency]: EventHandlers.HighMediaLatencyEvent; + [QualityEvents.NoAudioSignal]: EventHandlers.NoAudioSignalEvent; + [QualityEvents.NoAudioReceive]: EventHandlers.NoAudioReceiveEvent; + [QualityEvents.NoVideoReceive]: EventHandlers.NoVideoReceiveEvent; + } + + // -- Structures + // Client Config + export interface ClientConfig { + enableVideo?: boolean; + enableCameraMirroring?: boolean; + enableLogcatLogging?: boolean; + preferredVideoCodec?: VideoCodec; + enableDebugLogging?: boolean; + logLevel?: LogLevel; + bundleId?: string | null; + requestAudioFocusMode?: boolean; + forceRelayTraffic?: boolean; + } + // Connect Options + export interface ConnectOptions { + connectivityCheck?: boolean; + servers?: string[]; + } + // Login Tokens + export interface LoginTokens { + accessExpire: number; + accessToken: string; + refreshExpire: number; + refreshToken: string; + } + // Video Flags + export interface VideoFlags { + receiveVideo?: boolean; + sendVideo?: boolean; + } + // Call Settings + export interface CallSettings { + preferredVideoCodec?: VideoCodec; + customData?: string | null; + extraHeaders?: Record; + video: VideoFlags; + setupCallKit?: boolean; + enableSimulcast?: boolean; + } + + // -- Enums + // Quality Issue Level + export enum QualityIssueLevel { + NONE = "None", + MINOR = "Minor", + MAJOR = "Major", + CRITICAL = "Critical", + } + } + + namespace Voximplant.Hardware { + export class AudioDeviceManager { + public static getInstance(): AudioDeviceManager; + + public on( + event: K, + handler: (event: AudioDeviceEventHandlers[K]) => void, + ): void; + + public off( + event: K, + handler?: (event: AudioDeviceEventHandlers[K]) => void, + ): void; + + public getActiveDevice(): Promise; + + public getAudioDevices(): Promise; + + public selectAudioDevice(audioDevice: AudioDevice): void; + + public callKitConfigureAudioSession(): void; + + public callKitReleaseAudioSession(): void; + + public callKitStartAudio(): void; + + public callKitStopAudio(): void; + } + + export enum AudioDeviceEvents { + DeviceChanged = "DeviceChanged", + DeviceListChanged = "DeviceListChanged", + } + export interface AudioDeviceEventHandlers { + [AudioDeviceEvents.DeviceChanged]: EventHandlers.DeviceChanged; + [AudioDeviceEvents.DeviceListChanged]: EventHandlers.DeviceListChanged; + } + + export class CameraManager { + public static getInstance(): CameraManager; + + public switchCamera(cameraType: CameraType): void; + + public setCameraResolution(width: number, height: number): void; + + public useOrientationEventListener(use: boolean): void; + + public on( + event: K, + handler: (event: CameraEventHandlers[K]) => void, + ): void; + + public off( + event: K, + handler?: (event: CameraEventHandlers[K]) => void, + ): void; + } + + export enum CameraEvents { + CameraDisconnected = "CameraDisconnected", + CameraError = "CameraError", + CameraSwitchDone = "CameraSwitchDone", + CameraSwitchError = "CameraSwitchError", + } + export interface CameraEventHandlers { + [CameraEvents.CameraDisconnected]: EventHandlers.CameraDisconnected; + [CameraEvents.CameraError]: EventHandlers.CameraError; + [CameraEvents.CameraSwitchDone]: EventHandlers.CameraSwitchDone; + [CameraEvents.CameraSwitchError]: EventHandlers.CameraSwitchError; + } + + export class AudioFile { + public url: string; + public looped: boolean; + public name: string; + + public initWithLocalFile( + name: string, + type: string, + usage: AudioFileUsage, + ): Promise; + + public loadFile(url: string, usage: AudioFileUsage): Promise; + + public play(looped: boolean): Promise; + + public stop(): Promise; + + public releaseResources(): void; + + public on( + event: K, + handler: (event: AudioFileEventHandlers[K]) => void, + ): void; + + public off( + event: K, + handler?: (event: AudioFileEventHandlers[K]) => void, + ): void; + } + + export enum AudioFileEventTypes { + Started = "Started", + Stopped = "Stopped", + } + export interface AudioFileEventHandlers { + [AudioFileEventTypes.Started]: EventHandlers.AudioFileStarted; + [AudioFileEventTypes.Stopped]: EventHandlers.AudioFileStopped; + } + + export enum AudioDevice { + BLUETOOTH = "Bluetooth", + EARPIECE = "Earpiece", + NONE = "None", + SPEAKER = "Speaker", + WIRED_HEADSET = "WiredHeadset", + } + + export enum CameraType { + FRONT = "front", + BACK = "back", + } + + export enum AudioFileUsage { + IN_CALL = "incall", + NOTIFICATION = "notification", + RINGTONE = "ringtone", + UNKNOWN = "unknown", + } + } + + namespace Voximplant.Messaging { + export class Messenger { + public on( + eventType: K, + event: (event: MessengerEventHandlers[K]) => void, + ): void; + + public off( + eventType: K, + event?: (event: MessengerEventHandlers[K]) => void, + ): void; + + public getMe(): string | null; + + public getUserByName( + username: string, + ): Promise< + MessengerEventHandlers["GetUser"] | MessengerEventHandlers["Error"] + >; + + public getUserByIMId( + userId: number, + ): Promise< + MessengerEventHandlers["GetUser"] | MessengerEventHandlers["Error"] + >; + + public getUsersByName( + users: string[], + ): Promise< + MessengerEventHandlers["GetUser"][] | MessengerEventHandlers["Error"] + >; + + public getUsersByIMId( + users: number[], + ): Promise< + MessengerEventHandlers["GetUser"][] | MessengerEventHandlers["Error"] + >; + + public editUser( + customData: object | null, + privateCustomData: object | null, + ): Promise< + MessengerEventHandlers["EditUser"] | MessengerEventHandlers["Error"] + >; + + public setStatus( + online: boolean, + ): Promise< + MessengerEventHandlers["SetStatus"] | MessengerEventHandlers["Error"] + >; + + public subscribe( + users: number[], + ): Promise< + MessengerEventHandlers["Subscribe"] | MessengerEventHandlers["Error"] + >; + + public unsubscribe( + users: number[], + ): Promise< + MessengerEventHandlers["Unsubscribe"] | MessengerEventHandlers["Error"] + >; + + public unsubscribeFromAll(): Promise< + MessengerEventHandlers["Unsubscribe"] | MessengerEventHandlers["Error"] + >; + + public getSubscriptions(): Promise< + | MessengerEventHandlers["GetSubscriptions"] + | MessengerEventHandlers["Error"] + >; + + public managePushNotifications( + notifications: MessengerNotification[], + ): Promise< + MessengerEventHandlers["EditUser"] | MessengerEventHandlers["Error"] + >; + + public createConversation( + conversationConfig?: ConversationConfig, + ): Promise< + | MessengerEventHandlers["CreateConversation"] + | MessengerEventHandlers["Error"] + >; + + public getConversation( + uuid: string, + ): Promise< + | MessengerEventHandlers["GetConversation"] + | MessengerEventHandlers["Error"] + >; + + public getConversations( + uuids: string[], + ): Promise< + | MessengerEventHandlers["GetConversation"][] + | MessengerEventHandlers["Error"] + >; + + public getPublicConversations(): Promise< + | MessengerEventHandlers["GetPublicConversations"] + | MessengerEventHandlers["Error"] + >; + + public joinConversation( + uuid: string, + ): Promise< + | MessengerEventHandlers["GetPublicConversations"] + | MessengerEventHandlers["Error"] + >; + + public leaveConversation( + uuid: string, + ): Promise< + | MessengerEventHandlers["GetPublicConversations"] + | MessengerEventHandlers["Error"] + >; + } + + export class Conversation { + public createdTime: number; + public customData: object; + public direct: boolean; + public lastSequence: number; + public lastUpdateTime: number; + public participants: ConversationParticipant[]; + public publicJoin: boolean; + public title: string; + public uuid: string; + public uber: boolean; + + public setCustomData(customData: object): void; + + public setPublicJoin(publicJoin: boolean): void; + + public setTitle(title: string): void; + + public addParticipants( + participants: ConversationParticipant[], + ): Promise< + | MessengerEventHandlers["EditConversation"] + | MessengerEventHandlers["Error"] + >; + + public editParticipants( + participants: ConversationParticipant[], + ): Promise< + | MessengerEventHandlers["EditConversation"] + | MessengerEventHandlers["Error"] + >; + + public removeParticipants( + participants: ConversationParticipant[], + ): Promise< + | MessengerEventHandlers["EditConversation"] + | MessengerEventHandlers["Error"] + >; + + public update(): Promise< + | MessengerEventHandlers["EditConversation"] + | MessengerEventHandlers["Error"] + >; + + public typing(): Promise< + MessengerEventHandlers["Typing"] | MessengerEventHandlers["Error"] + >; + + public sendMessage( + text: string, + payload?: object[], + ): Promise< + MessengerEventHandlers["SendMessage"] | MessengerEventHandlers["Error"] + >; + + public markAsRead( + sequence: number, + ): Promise< + MessengerEventHandlers["Read"] | MessengerEventHandlers["Error"] + >; + + public retransmitEvents( + from: number, + to: number, + ): Promise< + | MessengerEventHandlers["RetransmitEvents"] + | MessengerEventHandlers["Error"] + >; + + public retransmitEventsFrom( + from: number, + count: number, + ): Promise< + | MessengerEventHandlers["RetransmitEvents"] + | MessengerEventHandlers["Error"] + >; + + public retransmitEventsTo( + to: number, + count: number, + ): Promise< + | MessengerEventHandlers["RetransmitEvents"] + | MessengerEventHandlers["Error"] + >; + } + + export class Message { + public conversation: string; + public payload: { [key: string]: any }[]; + public sequence: number; + public text: string; + public uuid: string; + + public update( + text: string | null, + payload: { [key: string]: any }[] | null, + ): Promise< + MessengerEventHandlers["EditMessage"] | MessengerEventHandlers["Error"] + >; + + public remove(): Promise< + | MessengerEventHandlers["RemoveMessage"] + | MessengerEventHandlers["Error"] + >; + } + + export enum MessengerEventTypes { + CreateConversation = "CreateConversation", + EditConversation = "EditConversation", + EditMessage = "EditMessage", + EditUser = "EditUser", + Error = "Error", + GetConversation = "GetConversation", + GetPublicConversations = "GetPublicConversations", + GetSubscriptions = "GetSubscriptions", + GetUser = "GetUser", + Read = "Read", + RemoveConversation = "RemoveConversation", + RemoveMessage = "RemoveMessage", + RetransmitEvents = "RetransmitEvents", + SendMessage = "SendMessage", + SetStatus = "SetStatus", + Subscribe = "Subscribe", + Typing = "Typing", + Unsubscribe = "Unsubscribe", + } + export interface MessengerEventHandlers { + [MessengerEventTypes.CreateConversation]: EventHandlers.ConversationEvent; + [MessengerEventTypes.EditConversation]: EventHandlers.ConversationEvent; + [MessengerEventTypes.EditMessage]: EventHandlers.MessageEvent; + [MessengerEventTypes.EditUser]: EventHandlers.UserEvent; + [MessengerEventTypes.Error]: EventHandlers.ErrorEvent; + [MessengerEventTypes.GetConversation]: EventHandlers.ConversationEvent; + [MessengerEventTypes.GetPublicConversations]: EventHandlers.ConversationListEvent; + [MessengerEventTypes.GetSubscriptions]: EventHandlers.SubscriptionEvent; + [MessengerEventTypes.GetUser]: EventHandlers.UserEvent; + [MessengerEventTypes.Read]: EventHandlers.ConversationServiceEvent; + [MessengerEventTypes.RemoveConversation]: EventHandlers.ConversationEvent; + [MessengerEventTypes.RemoveMessage]: EventHandlers.MessageEvent; + [MessengerEventTypes.RetransmitEvents]: EventHandlers.RetransmitEvent; + [MessengerEventTypes.SendMessage]: EventHandlers.MessageEvent; + [MessengerEventTypes.SetStatus]: EventHandlers.StatusEvent; + [MessengerEventTypes.Subscribe]: EventHandlers.SubscriptionEvent; + [MessengerEventTypes.Typing]: EventHandlers.TypingEvent; + [MessengerEventTypes.Unsubscribe]: EventHandlers.SubscriptionEvent; + } + + export enum MessengerAction { + addParticipants = "addParticipants", + createConversation = "createConversation", + editConversation = "editConversation", + editMessage = "editMessage", + editParticipants = "editParticipants", + editUser = "editUser", + getConversation = "getConversation", + getConversations = "getConversations", + getPublicConversations = "getPublicConversations", + getSubscriptions = "getSubscriptions", + getUser = "getUser", + getUsers = "getUsers", + joinConversation = "joinConversation", + leaveConversation = "leaveConversation", + manageNotifications = "manageNotifications", + read = "read", + removeConversation = "removeConversation", + removeMessage = "removeMessage", + removeParticipants = "removeParticipants", + retransmitEvents = "retransmitEvents", + sendMessage = "sendMessage", + setStatus = "setStatus", + subscribe = "subscribe", + typing = "typing", + unsubscribe = "unsubscribe", + } + + export enum MessengerNotification { + EditMessage = "EditMessage", + SendMessage = "SendMessage", + } + + // -- Structures + // User + export interface User { + name: string; + imId: number; + displayName: string; + customData: object; + privateCustomData: object; + conversationList: string[]; + leaveConversationList: string[]; + notifications: object[]; + isDeleted: boolean; + } + // Conversation Participant + export interface ConversationParticipant { + imUserId: number; + canWrite?: boolean; + canManageParticipants?: boolean; + canEditMessages?: boolean; + canEditAllMessages?: boolean; + canRemoveMessages?: boolean; + canRemoveAllMessages?: boolean; + owner?: boolean; + lastReadEventSequence?: number; + } + // Conversation Config + export interface ConversationConfig { + customData?: object; + direct?: boolean; + publicJoin?: boolean; + participants: ConversationParticipant[]; + title?: string; + uber?: boolean; + } + } + + namespace EventHandlers { + // -- Call Events + import CallEvents = Voximplant.CallEvents; + // Connected, Progress Tone Start + export interface CallEventWithHeaders { + name: CallEvents.Connected | CallEvents.ProgressToneStart; + call: Voximplant.Call; + headers?: object; + } + // Disconnected + export interface Disconnected extends Omit { + name: CallEvents.Disconnected; + answeredElsewhere: boolean; + } + // Endpoint Added + export interface EndpointAdded { + name: CallEvents.EndpointAdded; + call: Voximplant.Call; + endpoint: Voximplant.Endpoint; + } + // Failed + export interface Failed extends Omit { + name: CallEvents.Failed; + code: number; + reason: string; + } + /* ICECompleted, ICETimeout, Progress Tone Stop, Call Reconnecting, + Call Reconnected */ + export interface CallEvent { + name: + | CallEvents.ICECompleted + | CallEvents.ICETimeout + | CallEvents.ProgressToneStop + | CallEvents.CallReconnecting + | CallEvents.CallReconnected; + call: Voximplant.Call; + } + // Info Received + export interface InfoReceived extends Omit { + name: CallEvents.InfoReceived; + mimeType: string; + body: string; + } + // Local Video Stream Added + interface VideoStreamEvent { + call: Voximplant.Call; + videoStream: Voximplant.VideoStream; + } + export interface LocalVideoStreamAdded extends VideoStreamEvent { + name: CallEvents.LocalVideoStreamAdded; + } + // Local Video Stream Removed + export interface LocalVideoStreamRemoved extends VideoStreamEvent { + name: CallEvents.LocalVideoStreamRemoved; + } + // Message Received + export interface MessageReceived { + name: CallEvents.MessageReceived; + call: Voximplant.Call; + text: string; + } + // Call Operation Failed + export interface CallOperationFailed { + name: string; + code: Voximplant.CallError; + message: string; + } + + // -- Endpoint Events + import EndpointEvents = Voximplant.EndpointEvents; + interface EndpointEvent { + endpoint: Voximplant.Endpoint; + call: Voximplant.Call; + } + // Info Updated + export interface InfoUpdated extends EndpointEvent { + name: EndpointEvents.InfoUpdated; + } + // Remote Video Stream Added + export interface RemoteVideoStreamAdded + extends EndpointEvent, + VideoStreamEvent { + name: EndpointEvents.RemoteVideoStreamAdded; + } + // Remote Video Stream Removed + export interface RemoteVideoStreamRemoved + extends EndpointEvent, + VideoStreamEvent { + name: EndpointEvents.RemoteVideoStreamRemoved; + } + // Removed + export interface Removed extends EndpointEvent { + name: EndpointEvents.Removed; + } + // Voice Activity Started, Voice Activity Stopped + export interface EndpointDefaultEvent extends EndpointEvent { + name: + | EndpointEvents.VoiceActivityStarted + | EndpointEvents.VoiceActivityStopped; + } + // Start Receiving Video Stream + export interface StartReceivingVideoStream + extends EndpointEvent, + VideoStreamEvent { + name: EndpointEvents.StartReceivingVideoStream; + } + // Stop Receiving Video Stream + export interface StopReceivingVideoStream + extends EndpointEvent, + VideoStreamEvent { + name: EndpointEvents.StopReceivingVideoStream; + reason: Voximplant.VideoStreamReceiveStopReason; + } + + // -- Quality Events + import QualityEvents = Voximplant.QualityEvents; + interface QualityEvent { + callId: string; + issueLevel: Voximplant.QualityIssueLevel; + } + // Packet Loss + export interface PacketLossEvent extends QualityEvent { + name: QualityEvents.PacketLoss; + packetLoss: number; + } + // Codec Mismatch + export interface CodecMismatchEvent extends QualityEvent { + name: QualityEvents.CodecMismatch; + codec: string | null; + } + // Local Video Degradation + export interface LocalVideoDegradationEvent extends QualityEvent { + name: QualityEvents.LocalVideoDegradation; + actualSize: object; + targetSize: object; + } + // Ice Disconnected + export interface IceDisconnectedEvent extends QualityEvent { + name: QualityEvents.IceDisconnected; + } + // High Media Latency + export interface HighMediaLatencyEvent extends QualityEvent { + name: QualityEvents.HighMediaLatency; + latency: number; + } + // No Audio Signal + export interface NoAudioSignalEvent extends QualityEvent { + name: QualityEvents.NoAudioSignal; + } + // No Audio Receive + export interface NoAudioReceiveEvent extends QualityEvent { + name: QualityEvents.NoAudioReceive; + audioStreamId: string; + endpointId: string; + } + // No Video Receive + export interface NoVideoReceiveEvent extends QualityEvent { + name: QualityEvents.NoVideoReceive; + videoStreamId: string; + endpointId: string; + } + + // -- Client Events + import ClientEvents = Voximplant.ClientEvents; + // Connection Established + export interface ConnectionEstablished { + name: ClientEvents.ConnectionEstablished; + } + // Connection Failed + export interface ConnectionFailed { + name: ClientEvents.ConnectionFailed; + message: string; + } + // Connection Closed + export interface ConnectionClosed { + name: ClientEvents.ConnectionClosed; + } + // Auth Result + export interface AuthResult { + name: ClientEvents.AuthResult; + result: boolean; + code: number; + displayName: string; + key: string; + tokens: Voximplant.LoginTokens; + } + // Refresh Token Result + export interface AuthTokenResult { + name: ClientEvents.RefreshTokenResult; + result: boolean; + code: number; + tokens: Voximplant.LoginTokens; + } + // Incoming Call + export interface IncomingCall { + name: ClientEvents.IncomingCall; + call: Voximplant.Call; + headers?: object; + video: boolean; + } + // Reconnecting + export interface Reconnecting { + name: ClientEvents.Reconnecting; + } + // Reconnected + export interface Reconnected { + name: ClientEvents.Reconnected; + } + + // -- Audio Device Events + import AudioDeviceEvents = Voximplant.Hardware.AudioDeviceEvents; + // Device Changed + export interface DeviceChanged { + name: AudioDeviceEvents.DeviceChanged; + currentDevice: Voximplant.Hardware.AudioDevice; + } + // Device List Changed + export interface DeviceListChanged { + name: AudioDeviceEvents.DeviceListChanged; + newDeviceList: Voximplant.Hardware.AudioDevice[]; + } + + // -- Camera Events + import CameraEvents = Voximplant.Hardware.CameraEvents; + // Camera Disconnected + export interface CameraDisconnected { + name: CameraEvents.CameraDisconnected; + } + // Camera Error + export interface CameraError { + name: CameraEvents.CameraError; + error: string; + } + // Camera Switch Done + export interface CameraSwitchDone { + name: CameraEvents.CameraSwitchDone; + isFrontCamera: boolean; + } + // Camera Switch Error + export interface CameraSwitchError { + name: CameraEvents.CameraSwitchError; + error: string; + } + + // -- Audio File Events + import AudioFileEventTypes = Voximplant.Hardware.AudioFileEventTypes; + // Audio File Started + interface AudioFileEvent { + audioFile: Voximplant.Hardware.AudioFile; + result: boolean; + error: string; + } + export interface AudioFileStarted extends AudioFileEvent { + name: AudioFileEventTypes.Started; + } + // Audio File Stopped + export interface AudioFileStopped extends AudioFileEvent { + name: AudioFileEventTypes.Stopped; + } + + // -- Messenger Events + import MessengerEventTypes = Voximplant.Messaging.MessengerEventTypes; + interface MessengerEvent { + action: Voximplant.Messaging.MessengerAction; + } + // Create Conversation, Edit Conversation, Get Conversation, Remove Conversation + export interface ConversationEvent extends MessengerEvent { + eventType: + | MessengerEventTypes.CreateConversation + | MessengerEventTypes.EditConversation + | MessengerEventTypes.GetConversation + | MessengerEventTypes.RemoveConversation; + conversation: Voximplant.Messaging.Conversation; + sequence: number; + timestamp: number; + imUserId: number; + } + // Edit Message, Remove Message, Send Message + export interface MessageEvent extends MessengerEvent { + eventType: + | MessengerEventTypes.EditMessage + | MessengerEventTypes.RemoveMessage + | MessengerEventTypes.SendMessage; + message: Voximplant.Messaging.Message; + sequence: number; + timestamp: number; + imUserId: number; + } + // Edit User, Get User + export interface UserEvent extends MessengerEvent { + eventType: + | MessengerEventTypes.EditUser + | MessengerEventTypes.GetUser + | MessengerEventTypes.SetStatus; + user: Voximplant.Messaging.User; + imUserId: number; + } + // Error + export interface ErrorEvent extends MessengerEvent { + eventType: MessengerEventTypes.Error; + code: number; + description: string; + } + // Get Public Conversations + export interface ConversationListEvent extends MessengerEvent { + eventType: MessengerEventTypes.GetPublicConversations; + conversationList: string[]; + imUserId: number; + } + // Get Subscriptions, Subscribe, Unsubscribe + export interface SubscriptionEvent extends MessengerEvent { + eventType: + | MessengerEventTypes.GetSubscriptions + | MessengerEventTypes.Subscribe + | MessengerEventTypes.Unsubscribe; + imUserId: number; + users: number[]; + } + // Read + export interface ConversationServiceEvent extends MessengerEvent { + eventType: MessengerEventTypes.Read; + imUserId: number; + conversationUUID: string; + sequence: number; + } + // Retransmit Events + export interface RetransmitEvent extends MessengerEvent { + eventType: MessengerEventTypes.RetransmitEvents; + imUserId: number; + from: number; + to: number; + events: object[]; + } + // Set Status + export interface StatusEvent extends MessengerEvent { + eventType: MessengerEventTypes.SetStatus; + imUserId: number; + online: boolean; + } + // Typing + export interface TypingEvent extends MessengerEvent { + eventType: MessengerEventTypes.Typing; + imUserId: number; + conversationUUID: string; + } + } +} diff --git a/package.json b/package.json index 38d438e..d76b99f 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.40.1", "description": "VoxImplant Mobile SDK for embedding voice and video communication into React Native apps.", "nativePackage": true, + "types": "index.d.ts", "keywords": [ "react-native", "react",