TUICallEvent

TUICallEvent API Introduction

TUICallEvent API is the Event Interface of the Audio and Video Call Components.

Event List

EVENT
Description
An error occurred during the call.
This event is received when the SDK enters the ready state
Receiving this event after a duplicate sign-in indicates that the user has been removed from the room
If a user answers, this event will be received
A user joined the call.
A user left the call.
A user declined the call.
A user didn't respond.
A user was busy.
Whether a user has a video stream.
Whether a user has an audio stream.
The volume levels of all users.
Group Chat Update, Invitation List this callback will be received
Call connected event, v1.4.6+ supported
A call was received. It will be discarded later and it is recommended to use TUICallEvent.ON_CALL_RECEIVED
Call request event, v1.4.6+ supported
Call cancellation event, It will be abandoned later and it is recommended to use TUICallEvent.ON_CALL_CANCELED
Call cancellation event, v1.4.6+ supported
Call connected event, v1.4.6+ supported
The call ended.
Device list update, this event will be received
Call type switching, this event will be received
All user network quality events, v3.0.7+ supported

ERROR

Error event during the call. You can capture internal errors during the call by monitoring this event.
let onError = function(error) {
console.log(error.code, error.msg);
};
tuiCallEngine.on(TUICallEvent.ERROR, onError);
The parameters are described below:
Parameter
Type
Meaning
code
Number
msg
String
Error message

SDK_READY

TUICallEngine relies on @tencentcloud/chat SDK. The SDK_READY event will be triggered only after successful login, and then you can use various functions of the SDK.
let onSDKReady = function(event) {
console.log(event);
};
tuiCallEngine.on(TUICallEvent.SDK_READY, onSDKReady);

KICKED_OUT

The current user was kicked offline:At this time, you can prompt the user with a UI message and then invoke login again.
let handleOnKickedOut = function(event) {
console.log(event);
};
tuiCallEngine.on(TUICallEvent.KICKED_OUT, handleOnKickedOut);

USER_ACCEPT

If a user answers, all other users will receive this event, where `userID` is the user who answered.
1. In a 1v1 call: when the callee answers, the caller will throw this event.
2. In group calls: if A calls B and C, and B answers, both A and C will throw this event, with the event's `userID` being B. Similarly, if C answers, both A and B will throw this event, with the event's `userID` being C.
let handleUserAccept = function(event) {
console.log(event.userID);
};
tuiCallEngine.on(TUICallEvent.USER_ACCEPT, handleUserAccept);
The parameters are described below:
Parameter
Type
Meaning
userID
String
Answering User ID

USER_ENTER

If a user enters the call, other users will throw this event, and userID is the user name who entered the call.
let handleUserEnter = function(event) {
console.log(event.userID);
};
tuiCallEngine.on(TUICallEvent.USER_ENTER, handleUserEnter);
The parameters are described below:
Parameter
Type
Meaning
userID
String
Entering User ID

USER_LEAVE

When a user leaves the call, this event will be thrown by other users in the call. The userID is the name of the user who left the call.
let handleUserLeave = function(event) {
console.log(event.userID);
};
tuiCallEngine.on(TUICallEvent.USER_LEAVE, handleUserLeave);
The parameters are described below:
Parameter
Type
Meaning
userID
String
Exiting User ID

REJECT

This event is thrown when the call is rejected
1. In a 1v1 call, only the calling party will receive the rejection event, and userID is the called username.
2. In a group call, when an invitee refuses the call, this event will be thrown by other people in the group call. The userID is the name of the user who refused the call.
let handleInviteeReject = function(event) {
console.log(event.userID);
};
tuiCallEngine.on(TUICallEvent.REJECT, handleInviteeReject);
The parameters are described below:
Parameter
Type
Meaning
userID
String
Rejecting User ID

NO_RESP

This event will be thrown by other calling users when the callee does not respond.
In a 1v1 call, only the initiator will receive the event of no answer. For example, A invites B, B does not answer, A can receive this event.
In a group call, when an invitee does not respond, this event will be thrown by everyone else in the group call. For example, if A invites B and C to join the call, but B does not respond, both A and C will throw this event.
let handleNoResponse = function(event) {
console.log(event.sponsor, event.userIDList);
};
tuiCallEngine.on(TUICallEvent.NO_RESP, handleNoResponse);
The parameters are described below:
Parameter
Type
Meaning
sponsor
String
Caller's User ID
userIDList
Array<String>
List of Users Who Triggered Timeout Due to No Response

LINE_BUSY

Call busy event. For example: when B is on a call, and A calls B, A will throw an event.
let handleLineBusy = function(event) {
console.log(event);
};
tuiCallEngine.on(TUICallEvent.LINE_BUSY, handleLineBusy);
The parameters are described below:
Parameter
Type
Meaning
userID
String
Busy User ID

USER_VIDEO_AVAILABLE

If a user turns on/off the camera during a video call, this event will be thrown by other users in the call. For example: A and B are on a video call, A turns on/off the camera, and B will throw this event.
let handleUserVideoChange = function(event) {
console.log(event.userID, event.isVideoAvailable);
};
tuiCallEngine.on(TUICallEvent.USER_VIDEO_AVAILABLE, handleUserVideoChange);
The parameters are described below:
Parameter
Type
Meaning
userID
String
Remote User ID
isVideoAvailable
Boolean
true: Remote User turns Camera On; false: Remote User turns Camera Off

USER_AUDIO_AVAILABLE

If a user turns on/off the microphone during an audio or video call, this event will be thrown by other users on the call. For example: A and B are having an audio and video call, and A turns on/off the microphone, and B will throw this event.
let handleUserAudioChange = function(event) {
console.log(event.userID, event.isAudioAvailable);
};
tuiCallEngine.on(TUICallEvent.USER_AUDIO_AVAILABLE, handleUserAudioChange);
The parameters are described below:
Parameter
Type
Meaning
userID
String
User ID to turn microphone on/off
isAudioAvailable
Boolean
true the user turns on the microphone; false the user turns off the microphone

USER_VOICE_VOLUME

When the user's volume changes during an audio or video call, this event will be thrown by other users on the call. For example: A and B are having an audio and video call, and if A's volume changes, B will throw this event.
let handleUserVoiceVolumeChange = function(event) {
console.log(event.volumeMap);
};
tuiCallEngine.on(TUICallEvent.USER_VOICE_VOLUME, handleUserVoiceVolumeChange);
The parameters are described below:
Parameter
Type
Meaning
volumeMap
Array<Object>
Volume meter, the corresponding volume can be obtained according to each userid, volume range: [0, 100]

GROUP_CALL_INVITEE_LIST_UPDATE

Group chat update invitation list, this event will be received.
let handleGroupInviteeListUpdate = function(event) {
console.log(event.userIDList);
};
tuiCallEngine.on(TUICallEvent.GROUP_CALL_INVITEE_LIST_UPDATE, handleGroupInviteeListUpdate);
The parameters are described below:
Parameter
Type
Meaning
userIDList
Array<String>
Group update invitation list

INVITED

Receiving a new incoming call event, the called party will be notified. By listening to this event, you can decide whether to display the call answering interface.
Note:
Plan to deprecate in subsequent versions. Recommended: ON_CALL_RECEIVED.

ON_CALL_RECEIVED

Receiving a new incoming call event, the called party will be notified. By listening to this event, you can decide whether to display the call answering interface.
Note:
v1.4.6+ supported.
let handleOnCallReceived = function(event) {
console.log(event);
};
tuiCallEngine.on(TUICallEvent.ON_CALL_RECEIVED, handleOnCallReceived);
The parameters are described below:
Parameter
Type
Meaning
sponsor
String
Inviter
userIDList
Array<String>
Also Invited Persons
isFromGroup
Boolean
Is it a Group Call
inviteData
Object
Call Data
inviteID
String
Invitation ID, identifying one invitation
userData
String
Extended field: Utilized for amplifying details in the invitation signaling
callId
String
Unique ID for this call
roomID
Number
Audio-Video Room ID for this call
callMediaType
Number
Media Type of the call, Video Call, Voice Call
callRole
String
role, Enumeration Type: Caller, Called

CALLING_CANCEL

If the call is not established, this event will be thrown. By listening to this event, you can implement display logic similar to missed calls, reset UI state, etc. Scenarios where the call is not established include:
Note:
Plan to deprecate in subsequent versions. Recommended: ON_CALL_CANCELED.

ON_CALL_CANCELED

If the call is not established, this event will be thrown. By listening to this event, you can implement display logic similar to missed calls, reset UI state, etc. Scenarios where the call is not established include:
Caller Cancelled: The caller throws this event, userID is the caller; the called also throws this event, userID is the called;
Callee Timeout: The caller will throw both NO_RESP and CALLING_CANCEL events, userID is the caller; the called throws the CALLING_CANCEL event, userID is the called;
Callee Rejected: The caller will throw both REJECT and CALLING_CANCEL events, userID is the caller; the called throws the CALLING_CANCEL event, userID is the called;
Callee Busy: The caller will throw both LINE_BUSY and CALLING_CANCEL events, userID is the caller; the callee throws the CALLING_CANCEL event, userID is the callee;
Note:
Supported from version v1.4.6+ .
let handleOnCallCanceled = function(event) {
console.log(event.userID);
};
tuiCallEngine.on(TUICallEvent.ON_CALL_CANCELED, handleOnCallCanceled);
The parameters are described below:
Parameter
Type
Meaning
userID
String
Cancelled User ID
callId
String
Unique ID for this call
roomID
Number
Audio-Video Room ID for this call
callMediaType
Number
Media Type of the call, Video Call, Voice Call
callRole
String
role, Enumeration Type: Caller, Called

ON_CALL_BEGIN

Indicates call connection. Both caller and called can receive it. You can start cloud recording, content review, etc., by listening to this event.
Note:
Supported from version v1.4.6+ .
let handleOnCallBegin = function(event) {
console.log(event);
};
tuiCallEngine.on(TUICallEvent.ON_CALL_BEGIN, handleOnCallBegin);
The parameters are described below:
Parameter
Type
Meaning
callId
String
Unique ID for this call
roomID
Number
Audio-Video Room ID for this call
callMediaType
Number
Media Type of the call, Video Call, Voice Call
callRole
String
role, Type: Caller, Called

CALLING_END

Indicates call termination. Both caller and called can trigger this event. You can display information such as call duration, call type, or stop the cloud recording process by listening to this event.
let handleCallingEnd = function(event) {
console.log(event.userID, event.);
};
tuiCallEngine.on(TUICallEvent.CALLING_END, handleCallingEnd);
The parameters are described below:
Parameter
Type
Meaning
roomID
Number
Audio-Video Room ID for this call, currently only supports numeric room number, future versions will support character string room numbers
callMediaType
Number
Media Type of the call, Video Call, Voice Call
callRole
String
role, Enumeration Type: Caller ('inviter'), Called ('invitee'), Unknown ('')
totalTime
Number
The duration of this call in seconds
userID
String
userID of the call termination.
callId
String
The unique ID for this call. v1.4.6+ Supported
callEnd
Number
The duration of this call (will be deprecated, Please use totalTime) in seconds

DEVICED_UPDATED

Device list update, this event will be received.
let handleDeviceUpdated = function({ microphoneList, cameraList, currentMicrophoneID, currentCameraID }) {
console.log(microphoneList, cameraList, currentMicrophoneID, currentCameraID)
};
tuiCallEngine.on(TUICallEvent.DEVICED_UPDATED, handleDeviceUpdated);

CALL_TYPE_CHANGED

Call type switching, this event will be received.
let handleCallTypeChanged = function({ oldCallType, newCallType }) {
console.log(oldCallType, newCallType)
};
tuiCallEngine.on(TUICallEvent.CALL_TYPE_CHANGED, handleDeviceUpdated);
The parameters are described below:
Parameter
Type
Meaning
oldCallType
Number
Old call type
newCallType
Number
New call type

ON_USER_NETWORK_QUALITY_CHANGED

All user network quality events
Note:
v3.0.7+ supported.
let handleOnUserNetworkQualityChange = function(event) {
console.log(event.networkQualityList);
};
tuiCallEngine.on(TUICallEvent.ON_USER_NETWORK_QUALITY_CHANGED, handleOnUserNetworkQualityChange);
The parameters are described below:
Parameter
Type
Meaning
networkQualityList
Array<Object>
Network status, according to userID, you can get the current network quality of the corresponding user.