-
Notifications
You must be signed in to change notification settings - Fork 10
/
SendBirdCall.min.d.ts
791 lines (667 loc) · 22.4 KB
/
SendBirdCall.min.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
/** 1.10.20 */
// eslint-disable-next-line no-undef,max-classes-per-file
export as namespace SendBirdCall;
export function init(appId: string, apiHost?: string, websocketHost?: string): void;
export function authenticate(authOption: AuthOption, handler?: AuthHandler): Promise<User>;
export function deauthenticate(): void;
export function connectWebSocket(): Promise<void>;
export function addListener(id: string, listener: SendBirdCallListener): void;
export function removeListener(id: string): void;
export function removeAllListeners(): void;
export function addRecordingListener(id: string, listener: SendBirdCallRecordingListener): void;
export function removeRecordingListener(id: string): void;
export function removeAllRecordingListeners(): void;
export function dial(params: DialParams, callback?: DialHandler): DirectCall;
export function createDirectCallLogListQuery(params?: DirectCallLogListQueryParams): DirectCallLogListQuery;
export function getCurrentAudioInputDevice(): InputDeviceInfo;
export function getAvailableAudioInputDevices(): InputDeviceInfo[];
export function selectAudioInputDevice(mediaDeviceInfo: InputDeviceInfo): void;
export function getCurrentAudioOutputDevice(): MediaDeviceInfo;
export function getAvailableAudioOutputDevices(): MediaDeviceInfo[];
export function selectAudioOutputDevice(mediaDeviceInfo: MediaDeviceInfo): void;
export function getCurrentVideoInputDevice(): InputDeviceInfo;
export function getAvailableVideoInputDevices(): InputDeviceInfo[];
export function selectVideoInputDevice(mediaDeviceInfo: InputDeviceInfo): void;
export function updateMediaDevices(constraints: { audio: boolean; video: boolean }): void;
export function useMedia(constraints: { audio: boolean; video: boolean }): MediaAccess | undefined;
export function updateCustomItems(callId: string, customItems: CustomItems, callback?: CustomItemsHandler): Promise<CustomItemsResult>;
export function deleteCustomItems(callId: string, customItemKeys: string[], callback?: CustomItemsHandler): Promise<CustomItemsResult>;
export function deleteAllCustomItems(callId: string, callback?: CustomItemsHandler): Promise<CustomItemsResult>;
export function setLoggerLevel(level: LoggerLevel): LoggerLevel;
export function getOngoingCalls(): DirectCall[];
export function getOngoingCallCount(): number;
export function setRingingTimeout(timeout: number): void;
export function setCallConnectionTimeout(timeout: number): void;
export function handleWebhookData(data: WebhookData): void;
export function addDirectCallSound(type: SoundType, url: string): Promise<boolean>;
export function removeDirectCallSound(type: SoundType): boolean;
export function getCall(callId: string): DirectCall;
export function createRoom(params: RoomParams): Promise<Room>;
export function getCachedRoomById(roomId: string): Room;
export function fetchRoomById(roomId: string): Promise<Room>;
export function createRoomListQuery(params: RoomListQueryParams): RoomListQuery;
export function registerPushToken(pushToken: string, tokenType: TokenType): Promise<void>;
export function unregisterPushToken(pushToken: string, tokenType: TokenType): Promise<void>;
export function unregisterAllPushTokens(tokenType: TokenType): Promise<void>;
export const sdkVersion: string;
export const appId: string;
export const currentUser: User;
export interface DialParams {
userId: string;
isVideoCall: boolean;
callOption: DirectCallOption;
customItems?: CustomItems;
sendBirdChatOptions?: SendBirdChatOptions;
holdActiveCall?: boolean;
webhook?: Webhook;
}
export interface AcceptParams {
callOption: DirectCallOption;
holdActiveCall?: boolean;
}
export enum LoggerLevel {
NONE = 'NONE',
ERROR = 'ERROR',
WARNING = 'WARNING',
INFO = 'INFO'
}
export enum SoundType {
DIALING = 'DIALING',
RINGING = 'RINGING',
RECONNECTING = 'RECONNECTING',
RECONNECTED = 'RECONNECTED',
}
export enum DirectCallUserRole {
CALLER = 'dc_caller',
CALLEE = 'dc_callee'
}
export enum DirectCallEndResult {
NO_ANSWER = 'no_answer',
CANCELED = 'canceled',
DECLINED = 'declined',
OTHER_DEVICE_ACCEPTED = 'other_device_accepted',
COMPLETED = 'completed',
CONNECTION_LOST = 'connection_lost',
TIMED_OUT = 'timed_out',
DIAL_FAILED = 'dial_failed',
ACCEPT_FAILED = 'accept_failed',
NOT_CONNECTED = 'not_connected',
UNKNOWN = 'unknown'
}
export enum TokenType {
APNS = 'apns_voip',
FCM = 'fcm_voip',
}
export enum ErrorCode {
// Call
DIAL_CANCELED= 1800100,
MY_USER_ID_NOT_ALLOWED= 1800101,
// Client
ERR_REQUEST_FAILED= 1800200,
WS_NOT_CONNECTED= 1800201,
WS_CONNECTION_FAILED= 1800202,
ERR_NO_RESPONSE_DUE_TO_TIMEOUT= 1800203,
ERR_REQUEST_FAILED_DUE_TO_WEBSOCKET_CONNECTION_LOST= 1800204,
ERR_WRONG_RESPONSE= 1800205,
ERR_QUERY_IN_PROGRESS= 1800206,
INTERNAL_SERVER_ERROR= 1800207,
ERR_MALFORMED_DATA= 1800208,
// Room
ERR_PARTICIPANT_ALREADY_IN_ROOM = 1800700,
ERR_ENTERING_ROOM_STILL_IN_PROGRESS = 1800701,
ERR_PARTICIPANT_NOT_IN_ROOM = 1800702,
ERR_EXITING_ROOM_STILL_IN_PROGRESS = 1800703,
ERR_FAILED_TO_ESTABLISH_CONNECTION_TO_SEND_STREAM = 1800704,
ERR_FAILED_TO_ESTABLISH_CONNECTION_TO_RECEIVE_STREAM = 1800705,
ERR_LOCAL_PARTICIPANT_LOST_CONNECTION = 1800706,
// Error for take snapshot
ERR_CAPTURE_NOT_ALLOWED_ON_AUDIO_CALL = 1800600,
ERR_VIDEO_VIEW_NOT_READY = 1800601,
ERR_VIDEO_CALL_NOT_CONNECTED_YET = 1800602,
ERR_FAILED_TO_GET_IMAGE_FROM_VIDEO_STREAM = 1800603,
// General
INVALID_PARAMETER_VALUE= 1800300,
INVALID_PARAMETER_TYPE= 1800301,
INSTANCE_NOT_INITIALIZED= 1800302,
USER_NOT_AUTHENTICATED= 1800303,
// Server
ERR_SERVER_INTERNAL_ERROR= 1400999,
ERR_INVALID_CALL_STATUS= 1400101,
ERR_CALL_DOES_NOT_EXIST= 1400102,
ERR_CALLEE_DOES_NOT_EXIST= 1400103,
ERR_DIAL_MYSELF= 1400104,
ERR_NO_PERMISSION= 1400105,
ERR_CALLEE_NEVER_AUTHENTICATE= 1400106,
// Recording
ERR_CALL_NOT_CONNECTED_YET = 1800610,
ERR_WRONG_RECORDING_TYPE_FOR_AUDIO_CALL = 1800611,
ERR_RECORDING_ALREADY_IN_PROGRESS = 1800612,
ERR_FAILED_TO_OPEN_FILE = 1800613,
ERR_FAILED_TO_START_RECORDING = 1800614,
ERR_FAILED_TO_STOP_RECORDING = 1800615,
ERR_NOT_SUPPORTED_BROWSER_FOR_RECORDING = 1800616,
ERR_INVALID_RECORDING_TYPE = 1800617,
ERR_NOT_SUPPORTED_OS_VERSION_FOR_RECORDING = 1800618,
// screen share
ERR_SCREEN_SHARE_RESTRICTED_FROM_AUDIO_CALL = 1800620,
ERR_SCREEN_SHARE_REQUEST_BEFORE_CALL_IS_CONNECTED = 1800621,
ERR_SCREEN_SHARE_ALREADY_IN_PROGRESS = 1800622,
ERR_NO_SCREEN_SHARE_EXISTS = 1800623,
ERR_NOT_SUPPORTED_BROWSER_FOR_SCREEN_SHARE = 1800625,
ERR_SCREEN_SHARE_FAILED_DUE_TO_UNKNOWN_REASON = 1800626,
ERR_NOT_SUPPORTED_APP_STATE_FOR_SCREEN_SHARE = 1800627,
ERR_PERMISSION_DENIED_FOR_SCREEN_SHARE = 1800628,
ERR_SELECTED_CONTENT_NOT_EXIST = 1800629,
ERR_SELECTED_CONTENT_INACCESSIBLE = 1800630,
}
export enum ConnectionQualityState {
UNAVAILABLE = 'unavailable',
POOR = 'poor',
FAIR = 'fair',
AVERAGE = 'average',
GOOD = 'good',
EXCELLENT = 'excellent',
}
export enum ConnectionQualityMonitoringMode {
FREQUENCY = 'frequency',
CONNECTION_QUALITY_CHANGE = 'connectionQualityChange',
}
export interface ConnectionMetrics {
mos?: number;
packetsLostRate?: number;
rtt?: number;
jitter?: number;
connectionQuality: ConnectionQualityState;
}
export interface SendBirdCallListener {
onRinging?: ((directCall: DirectCall) => void) | null;
onAudioInputDeviceChanged?: ((currentAudioInputDevice: InputDeviceInfo, availableAudioInputDevices: InputDeviceInfo[]) => void) | null;
onAudioOutputDeviceChanged?: ((currentAudioOutputDevice: MediaDeviceInfo, availableAudioOutputDevices: MediaDeviceInfo[]) => void) | null;
onVideoInputDeviceChanged?: ((currentVideoInputDevice: InputDeviceInfo, availableVideoInputDevices: InputDeviceInfo[]) => void) | null;
onInvitationReceived?: ((invitation: RoomInvitation) => void) | null;
}
export interface SendBirdCallRecordingListener {
onRecordingSucceeded: ((callId: string, recordingId: string, options: DirectCallRecordOption, fileName?: string) => void) | null;
onRecordingFailed: ((callId: string, recordingId: string, error: Error) => void) | null;
}
/**
* Event Target
*/
interface Event {
readonly args: any[];
}
declare type nullish = null | undefined;
declare type ArgsType<T extends Event> = T['args'] extends nullish ? [] : T['args'];
interface EventListener<T extends Event> {
(...args: ArgsType<T>): void;
}
declare type EventMap = Record<string, Event>;
declare type EventKey<T extends EventMap> = keyof T;
declare class EventTarget<T extends EventMap> {
/**
* Adds a listener to receive events.
*/
addEventListener<K extends EventKey<T>>(type: K, callback: EventListener<T[K]>): void;
/**
* Alias for addEventListener
*/
on: <K extends keyof T>(type: K, callback: EventListener<T[K]>) => void;
/**
* Adds listener to receive events once.
*/
once<K extends EventKey<T>>(type: K, givenCb: EventListener<T[K]>): void;
/**
* Removes an added listener.
*/
removeEventListener<K extends EventKey<T>>(type: K, callback: EventListener<T[K]>): void;
/**
* Alias for removeEventListener
*/
off: <K extends keyof T>(type: K, callback: EventListener<T[K]>) => void;
/**
* Removes all added listeners.
*/
removeAllEventListeners(): void;
}
/**
* DirectCall
*/
export interface DirectCall {
onEstablished: ((call: DirectCall) => void) | null;
onConnected: ((call: DirectCall) => void) | null;
onReconnected: ((call: DirectCall) => void) | null;
onReconnecting: ((call: DirectCall) => void) | null;
onRemoteAudioSettingsChanged: ((call: DirectCall) => void) | null;
onRemoteVideoSettingsChanged: ((call: DirectCall) => void) | null;
onCustomItemsUpdated: ((call: DirectCall, updatedKeys: string[]) => void) | null;
onCustomItemsDeleted: ((call: DirectCall, deletedKeys: string[]) => void) | null;
onRemoteRecordingStatusChanged: ((call: DirectCall) => void) | null;
onCalleeDialReceived: (call: DirectCall) => void | null;
onUserHoldStatusChanged: ((call: DirectCall, isLocalUser: boolean, isUserOnHold: boolean) => void) | null;
onEnded: ((call: DirectCall) => void) | null;
onScreenShareStopped: (() => void) | null;
readonly callId: string;
readonly caller: DirectCallUser;
readonly callee: DirectCallUser;
readonly isVideoCall: boolean;
readonly localUser: DirectCallUser;
readonly remoteUser: DirectCallUser;
readonly isLocalAudioEnabled: boolean;
readonly isRemoteAudioEnabled: boolean;
readonly isLocalVideoEnabled: boolean;
readonly isRemoteVideoEnabled: boolean;
readonly myRole: DirectCallUserRole;
readonly isOngoing: boolean;
readonly isOnHold: boolean;
readonly endedBy: DirectCallUser;
readonly isEnded: boolean;
readonly endResult: DirectCallEndResult;
readonly callLog: DirectCallLog;
readonly customItems: CustomItems;
readonly localRecordingStatus: RecordingStatus;
readonly remoteRecordingStatus: RecordingStatus;
readonly localMediaView: HTMLMediaElement;
readonly remoteMediaView: HTMLMediaElement;
readonly isLocalScreenShareEnabled: boolean;
setLocalMediaView(mediaView: HTMLMediaElement): Promise<void>;
setRemoteMediaView(mediaView: HTMLMediaElement): Promise<void>;
stopVideo(): void;
startVideo(): void;
getDuration(): number;
accept(params: AcceptParams): void;
end(): void;
muteMicrophone(): void;
unmuteMicrophone(): void;
hold(): Promise<void>;
unhold(force: boolean): Promise<void>;
captureLocalVideoView(callback?: CaptureVideoViewHandler): Promise<CaptureVideoViewResult>;
captureRemoteVideoView(callback?: CaptureVideoViewHandler): Promise<CaptureVideoViewResult>;
updateCustomItems(customItems: CustomItems, callback?: CustomItemsHandler): Promise<CustomItemsResult>;
deleteCustomItems(customItemsKeys: string[], callback?: CustomItemsHandler): Promise<CustomItemsResult>;
deleteAllCustomItems(callback?: CustomItemsHandler): Promise<CustomItemsResult>;
startRecording(options: DirectCallRecordOption): string;
stopRecording(recordId: string): boolean;
startScreenShare(): Promise<void>;
stopScreenShare(): void;
setConnectionQualityListener(mode: ConnectionQualityMonitoringMode, listener: (metrics: ConnectionMetrics) => void): void;
removeConnectionQualityListener(): void;
}
export interface DirectCallOption {
localMediaView?: HTMLMediaElement;
remoteMediaView?: HTMLMediaElement;
audioEnabled?: boolean;
videoEnabled?: boolean;
}
declare const DirectCallOption: {
new(option: DirectCallOption): DirectCallOption;
};
export interface DirectCallLogListQuery {
next(callback?: DirectCallLogListQueryResultHandler): Promise<DirectCallLog[]>;
readonly isLoading: boolean;
readonly hasNext: boolean;
}
export type DirectCallLogListQueryResultHandler = (callLogs?: DirectCallLog[], error?: Error) => void;
export interface DirectCallLog {
readonly callId: string;
readonly userRole: DirectCallUserRole;
readonly startedAt: Date;
readonly endedAt: Date;
readonly endedBy: DirectCallUser;
readonly duration: number;
readonly endResult: DirectCallEndResult;
readonly isVideoCall: boolean;
readonly customItems: CustomItems;
readonly isFromServer: boolean;
}
export interface DirectCallUser {
readonly userId: string;
readonly nickname: string;
readonly profileUrl: string;
readonly metaData: object;
readonly isActive: boolean;
readonly role: DirectCallUserRole;
}
export interface AuthOption {
userId: string;
accessToken?: string;
}
export type AuthHandler = (user?: User, error?: Error) => void;
export type DialHandler = (call?: DirectCall, error?: Error) => void;
export type CompletionHandler = (error?: Error) => void;
export type CustomItemsHandler = (result?: CustomItemsResult, error?: Error) => void;
export interface CustomItemsResult {
readonly customItems: CustomItems;
readonly affectedKeys: string[];
}
export type CaptureVideoViewHandler = (result?: CaptureVideoViewResult, error?: Error) => void;
export interface CaptureVideoViewResult {
readonly width: number;
readonly height: number;
readonly data: string;
}
export interface User {
readonly userId: string;
readonly nickname: string;
readonly profileUrl: string;
readonly metaData: string;
readonly isActive: string;
}
export interface RoomListQuery {
prev(): Promise<Room[]>;
next(): Promise<Room[]>;
readonly isLoading: boolean;
readonly hasPrev: boolean;
readonly hasNext: boolean;
}
export interface DirectCallLogListQueryParams {
myRole?: DirectCallUserRole;
endResults?: DirectCallEndResult[];
startedAt?: number;
endedAt?: number;
limit?: number;
}
export interface RoomListQueryParams {
type?: RoomType | 'all'
limit?: number;
state?: RoomState;
currentParticipantCount?: [number | undefined, number | undefined];
createdByUserIds?: string[]
roomIds?: string[]
createdAt?: [number | undefined, number | undefined];
}
export interface CustomItems {
[key: string]: string;
}
export interface Webhook {
url: string;
enabledEvents: string[];
headers?: {[key: string]: string};
}
export interface SendBirdChatOptions {
channelUrl: string;
}
export interface MediaAccess {
dispose(): void;
}
export interface RecordOption {
callId: string;
recordingType: RecordingType;
fileName?: string;
}
declare const RecordOption: {
new(option: RecordOption): RecordOption;
};
export interface DirectCallRecordOption extends RecordOption {}
declare const DirectCallRecordOption: {
new(option: DirectCallRecordOption): DirectCallRecordOption;
};
export enum RecordingType {
REMOTE_AUDIO_AND_VIDEO = 'remote_audio_and_video',
REMOTE_AUDIO_ONLY = 'remote_audio_only',
LOCAL_REMOTE_AUDIOS = 'local_remote_audios',
LOCAL_AUDIO_REMOTE_AUDIO_AND_VIDEO = 'local_audio_remote_audio_and_video',
LOCAL_AUDIO_AND_VIDEO_REMOTE_AUDIO = 'local_audio_and_video_remote_audio',
}
export enum RecordingStatus {
NONE = 'none',
RECORDING = 'recording',
}
/* eslint-disable babel/camelcase */
export interface WebhookData {
category: string;
occured_at: number;
application_id: string;
sendbird_call?: {
version: number;
message_id: string;
cmd: string;
type: string;
payload: any;
};
[key: string]: any;
}
/* eslint-enable babel/camelcase */
/**
* Room
*/
export interface RoomInvitation {
room: Room;
inviter: User;
invitee: User;
accept(): Promise<void>;
decline(): Promise<void>;
cancel(): Promise<void>;
}
declare type RoomEventMap = {
remoteParticipantEntered: { args: [RemoteParticipant]; };
remoteParticipantConnected: { args: [RemoteParticipant]; };
remoteParticipantExited: { args: [RemoteParticipant]; };
remoteParticipantStreamStarted: { args: [RemoteParticipant]; };
remoteAudioSettingsChanged: { args: [RemoteParticipant]; };
remoteVideoSettingsChanged: { args: [RemoteParticipant]; };
localParticipantDisconnected: { args: [LocalParticipant]; };
localParticipantReconnected: { args: [LocalParticipant]; };
customItemsUpdated: { args: [CustomItems, string[]] };
customItemsDeleted: { args: [CustomItems, string[]] };
invitationDeclined: { args: [RoomInvitation] };
invitationAccepted: { args: [RoomInvitation] };
invitationCanceled: { args: [RoomInvitation]}
deleted: { args: [] };
error: { args: [Error, Participant?] };
};
/**
* Called when remote participant has been entered
*/
export type RemoteParticipantEnteredEventListener = (participant: RemoteParticipant) => void;
/**
* Called when remote participant has been exited
*/
export type RemoteParticipantExitedEventListener = (participant: RemoteParticipant) => void;
/**
* Called when it's able to receive media stream from remote participant.
*/
export type RemoteParticipantStreamStartedEventListener = (participant: RemoteParticipant) => void;
/**
* Called when audio settings of remote participant has been changed
*/
export type RemoteAudioSettingsChangedEventListener = (participant: RemoteParticipant) => void;
/**
* Called when video settings of remote participant has been changed.
*/
export type RemoteVideoSettingsChangedEventListener = (participant: RemoteParticipant) => void;
export enum RoomType {
/**
* Type of a room that supports audio and video, can have up to 6 participants.
*/
LARGE_ROOM_FOR_AUDIO_ONLY = 'large_room_for_audio_only',
/**
* Type of a room that only supports audio and can have up to 20 participants.
*/
SMALL_ROOM_FOR_VIDEO = 'small_room_for_video',
}
export enum RoomState {
/**
* Indicates a room is open and available for group calls.
*/
OPEN = 'open',
/**
* Indicates a room is deleted.
*/
DELETED = 'deleted',
}
export declare class Room extends EventTarget<RoomEventMap> {
/**
* The ID of room
*/
readonly roomId: string;
/**
* The state of room
*/
readonly state: RoomState;
/**
* The customItems of room
*/
customItems: CustomItems;
/**
* Room type
*/
readonly roomType: RoomType;
/**
* Long value of the date when the room created at.
*/
readonly createdAt: number;
/**
* The ID of user who created the room
*/
readonly createdBy: string;
/**
* The list of all participants including local participant.
*/
readonly participants: Participant[];
/**
* The local participant.
*/
readonly localParticipant: LocalParticipant;
/**
* The list of remote participants.
*/
readonly remoteParticipants: RemoteParticipant[];
/**
* Enters a room
*/
enter(params: EnterParams): Promise<void>;
/**
* Exits a room
*/
exit(): void;
/**
* Sets audio for a large room
*/
setAudioForLargeRoom(mediaView: HTMLAudioElement): Promise<void>;
/**
* Fetch custom items
*/
fetchCustomItems(): Promise<CustomItemsResult>;
/**
* Update custom items
*/
updateCustomItems(customItems: CustomItems): Promise<CustomItemsResult>;
/**
* Delete custom items
*/
deleteCustomItems(customItemKeys: string[]): Promise<CustomItemsResult>;
/**
* Send invitation
*/
sendInvitation(invitee: string): Promise<RoomInvitation>;
/**
* delete a room
*/
delete(): Promise<void>;
}
export type RoomParams = {
/**
* An enum that represents different types of a room.
*/
roomType: RoomType;
/**
* The custom items of room
*/
customItems?: CustomItems;
}
/**
* A class that provides the methods to enable audio and video settings.
*/
export interface EnterParams {
/**
* Enables a participant's audio settings when entering a room.
*/
audioEnabled: boolean;
/**
* Enables a participant's video settings when entering a room.
*/
videoEnabled: boolean;
/**
* Kicks out any participants in the room who have the same user id as the user entering the room.
*/
kickSiblings?: boolean;
}
export enum ParticipantState {
/**
* The state when the participant has entered room
*/
ENTERED = 'entered',
/**
* The state when the participant has been connected.
*/
CONNECTED = 'connected',
/**
* The state when the participant has exit room
*/
EXITED = 'exited',
}
export interface Participant {
/**
* A unique identifier for a participant in a room.
*/
participantId: string;
/**
* The timestamp of when the participant enters the room, in Unix milliseconds.
*/
enteredAt: number;
/**
* The timestamp of when the participant information was updated within the room, in Unix milliseconds.
*/
updatedAt: number;
/**
* The timestamp of when the participant exited the room, in Unix milliseconds.
*/
exitedAt?: number;
/**
* The period from the time when the participant entered the room to the time the participant left the room, measured in seconds.
*/
duration?: number;
/**
* The state of the participant. Valid values are entered, exited, and connected.
*/
state: ParticipantState;
/**
* Indicates a user in Calls who corresponds to the participant.
*/
user: User;
/**
* Indicates whether the participant has enabled their audio.
*/
isAudioEnabled: boolean;
/**
* Indicates whether the participant has enabled their video.
*/
isVideoEnabled: boolean;
setMediaView(mediaView: HTMLMediaElement): Promise<void>;
}
export interface LocalParticipant extends Participant {
readonly isLocalParticipant: true;
/**
* Alias for setMediaView
*/
setLocalMediaView(mediaView: HTMLMediaElement): Promise<void>;
/**
* Stop the local audio.
*/
muteMicrophone(): void;
/**
* Start the local audio.
*/
unmuteMicrophone(): void;
/**
* Start the local video.
*/
stopVideo(): void;
/**
* Stop the local video.
*/
startVideo(): void;
}
export interface RemoteParticipant extends Participant {
readonly isLocalParticipant: false;
}