tencent cloud

Feedback

TUICallEvent

Last updated: 2024-05-08 11:39:30

    TUICallEvent API Introduction

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

    Event List

    EVENT
    Description
    An error occurred within the SDK
    This event is received when the SDK enters the Ready State
    Duplicate login, receiving this event indicates being removed from the room
    If a user answers the call, this event will be received
    If a user agrees to join the call, this event will be received
    If a user agrees to leave the call, this event will be received
    If a user declines the call, this event will be received
    If the invited user does not respond, this event will be received
    Invitee Busy Line, this event will be received
    If a remote user turned the camera On/Off, this event will be received
    If a remote user turned the microphone On/Off, this event will be received
    If a remote user adjusts speaking volume, this event will be received
    Group chat updates, Invitation List event received
    Receiving an invitation to a call, this event will be received
    Call Request Event
    When a call is not established, all call parties throw this event
    Event thrown upon call connection
    Receiving this event indicates the call has ended
    Device list update event received
    Call Type Switching event received

    ERROR

    An error occurred within the SDK, and it can be captured by monitoring this event to detect internal SDK errors.
    let onError = function(error) {
    console.log(error.code, error.msg);
    };
    tuiCallEngine.on(TUICallEvent.ERROR, onError);
    The parameters are described below:
    Parameter
    Type
    Meaning
    code
    int
    msg
    String
    Error message

    SDK_READY

    This event is received when the SDK enters the Ready State.
    let onSDKReady = function(event) {
    console.log(event);
    };
    tuiCallEngine.on(TUICallEvent.SDK_READY, onSDKReady);

    KICKED_OUT

    Duplicate login, receiving this event indicates being kicked out of the room.
    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, with the userID indicating the answering user.
    1. In 1v1 calls: When the callee connects, the caller throws this event.
    2. In group calls: When A calls B and C, and B answers, A and C throw this event, with the event's userID being B. Similarly, if C answers, A and B 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 agrees to enter the call, all other users will receive this event, with the userID indicating the user who agreed to enter 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, other users in the call will receive this event, with the userID indicating the departing user.
    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

    Call Rejection Event
    1. In a 1v1 call, only the caller will receive the rejection event, with the userID indicating the called party.
    2. In group calls, all invitees can receive this event, with the userID indicating the user who declined 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
    User ID of the declining call

    NO_RESP

    Invite user, no response event.
    In 1v1 calls, only the initiator receives the event of no response. For example, if A invites B and B doesn't respond, A can receive this event.
    In group calls, all invitees can receive this event. For example, if A invites B and C into a call and B doesn't respond, both A and C can receive 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
    Initiator's User ID
    userIDList
    Array<String>
    List of users with no response due to trigger timeout

    LINE_BUSY

    Busy Line Call 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 Line User ID

    USER_VIDEO_AVAILABLE

    If a remote user turned the camera On/Off, this event will be received.
    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 On Camera; false: Remote User Turns Off Camera

    USER_AUDIO_AVAILABLE

    If a remote user turned the microphone On/Off, this event will be received.
    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
    Remote User ID
    isAudioAvailable
    Boolean
    true: Remote User Turns On Microphone; false: Remote User Turns Off Microphone

    USER_VOICE_VOLUME

    If a remote user adjusts speaking volume, this event will be received.
    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 Map: Each userid can access the corresponding volume level, with a minimum volume of 0 and a maximum volume of 100

    GROUP_CALL_INVITEE_LIST_UPDATE

    Group chat updates, Invitation List event 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

    Received a new incoming call event. The called party will receive it. You can decide whether to display the Call Answering Interface by monitoring this event.
    Note:
    Plan to deprecate in subsequent versions
    let handleNewInvitationReceived = function(event) {
    console.log(event.sponsor, event.userIDList, event.isFromGroup, event.inviteData, event.inviteDate, event.inviteID);
    };
    tuiCallEngine.on(TUICallEvent.INVITED, handleNewInvitationReceived);
    The parameters are described below:
    Parameter
    Type
    Meaning
    sponsor
    String
    Inviter
    userIDList
    Array<String>
    People who are also invited
    isFromGroup
    Boolean
    Whether it is a group call
    inviteData
    Object
    Call Data
    inviteID
    String
    Invitation ID, identifies an invitation
    userData
    String
    Extended fields: Used to add additional information in the invitation signaling
    callId
    String
    Unique ID for this call.Supported in v1.4.6+
    roomID
    Number
    Audio/Video Room ID for this call.Supported in v1.4.6+
    callMediaType
    Number
    Media Type of the Call, Video Call, Voice call.Supported in v1.4.6+
    callRole
    String
    role, Enumeration Type: Caller, Called.Supported in v1.4.6+

    ON_CALL_RECEIVED

    Received a new incoming call event. The called party will receive it. You can decide whether to display the Call Answering Interface by monitoring this event.
    Note:
    Supported in v1.4.6+
    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>
    People who are also invited
    isFromGroup
    Boolean
    Whether it is a group call
    inviteData
    Object
    Call Data
    inviteID
    String
    Invitation ID, identifies an invitation
    userData
    String
    Extended fields: Used to add additional information in the invitation signaling
    callId
    String
    Unique ID for this call
    roomID
    Number
    The audio and 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 a call is not established, this event will be thrown. You can monitor this event to implement logic similar to missing calls, resetting UI state, etc. Scenarios where a call is not established include:
    Caller Cancelled: This event is thrown by the caller, with the userID indicating the caller; it is also thrown by the callee, with the userID indicating the callee;
    Callee Timeout: The caller will throw both the NO_RESP and CALLING_CANCEL events, with the userID indicating the caller; the callee will throw the CALLING_CANCEL event, with the userID indicating the callee;
    Callee Rejected: The caller will throw both the REJECT and CALLING_CANCEL events, with the userID indicating the caller; the callee will throw the CALLING_CANCEL event, with the userID indicating the callee;
    Busy Line: The caller will throw both the LINE_BUSY and CALLING_CANCEL events, with the userID indicating the caller; the callee will throw the CALLING_CANCEL event, with the userID indicating the callee;
    Note:
    Plan to deprecate in subsequent versions
    let handleCallingCancel = function(event) {
    console.log(event.userID);
    };
    tuiCallEngine.on(TUICallEvent.CALLING_CANCEL, handleCallingCancel);
    The parameters are described below:
    Parameter
    Type
    Meaning
    userID
    String
    User ID of the call cancellation
    callId
    String
    Unique ID for this call.Supported in v1.4.6+
    roomID
    Number
    Audio/Video Room ID for this call.Supported in v1.4.6+
    callMediaType
    Number
    Media Type of the Call, Video Call, Voice call.Supported in v1.4.6+
    callRole
    String
    role, Enumeration Type: Caller, Called.Supported in v1.4.6+

    ON_CALL_CANCELED

    If a call is not established, this event will be thrown. You can monitor this event to implement logic similar to missing calls, resetting UI state, etc. Scenarios where a call is not established include:
    Caller Cancelled: This event is thrown by the caller, with the userID indicating the caller; it is also thrown by the callee, with the userID indicating the callee;
    Callee Timeout: The caller will throw both the NO_RESP and CALLING_CANCEL events, with the userID indicating the caller; the callee will throw the CALLING_CANCEL event, with the userID indicating the callee;
    Callee Rejected: The caller will throw both the REJECT and CALLING_CANCEL events, with the userID indicating the caller; the callee will throw the CALLING_CANCEL event, with the userID indicating the callee;
    Busy Line: The caller will throw both the LINE_BUSY and CALLING_CANCEL events, with the userID indicating the caller; the callee will throw the CALLING_CANCEL event, with the userID indicating the callee;
    Note:
    Supported in 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
    User ID of the call cancellation
    callId
    String
    Unique ID for this call
    roomID
    Number
    The audio and 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 the caller and the callee can receive it. You can initiate cloud recording, content review, and other processes by monitoring this event.
    Note:
    Supported in 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
    The audio and 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 the caller and the callee can throw this event. You can monitor this event to display information such as call duration, call type, or to stop the cloud recording process.
    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
    The audio and video room ID for this call, currently only supports numeric room numbers, future versions will support 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
    The userID of the call termination.
    callId
    String
    Unique ID for this call.Supported in v1.4.6+
    callEnd
    Number
    The duration of this call ( Subsequently deprecated), in seconds

    DEVICED_UPDATED

    Device list update event 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 event 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
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support