tencent cloud

Feedback

TUICallEvent

Last updated: 2025-01-03 18:01:30

    TUICallEvent APIs

    TUICallEvent API is the Event Interface of the Audio and Video Call Components.
    Event
    Description
    Error Callback during Call
    Callback for a Call Request
    Callback for Call Cancellation
    Callback for Call Connection
    Callback for Call Termination
    xxxx User declines the call Callback
    xxxx User Non-response Callback
    xxxx User Busy Line Callback
    xxxx User Joins Call Callback
    A user left the call.
    Callback for a change in the Call's Media Type
    Current user kicked offline
    Ticket expired while online
    Whether a user has a video stream.
    Whether a user has an audio stream.
    The volume levels of all users.
    The network quality of all users.

    TUICallEvent details

    onError

    Error callback.
    TUICallKit.on(TUICallEvent.onError, (res: any) => {
    console.log('onError code=' + res.code + ',message=' + res.message);
    });
    Parameter
    Type
    Description
    code
    Number
    Error Code
    message
    String
    Error message

    onCallReceived

    Received a callback for a new incoming call request.
    TUICallKit.on(TUICallEvent.onCallReceived, (res: any) => {
    console.log('onCallReceived callerId=' + res.callerId);
    });
    Parameter
    Type
    Description
    callerId
    String
    Caller ID (inviter)
    calleeIdList
    Array<String>
    List of called IDs (invitees)
    groupId
    String
    Group Call ID
    callMediaType
    Number
    The media type of the call, such as video call, voice call.
    params.callMediaType = 0 : Voice Call.
    params.callMediaType = 1 : Video Call.
    userData
    String
    User-added extension fields.

    onCallCancelled

    Indicates the call was canceled by the caller, missed by the callee, rejected, etc., covering multiple scenarios.
    Caller Cancellation: The caller receives this callback (callerId is oneself); the callee receives this callback (callerId is the caller's ID)
    Callee Timeout: The caller receives both onUserNoResponse and onCallCancelled callbacks (callerId is their own ID); the callee receives the onCallCancelled callback (callerId is their own ID)
    Call rejected: The caller will receive both onUserReject and onCallCancelled callbacks (callerId is your own ID); the callee receives the onCallCancelled callback (callerId is your own ID)
    Call busy: The caller will receive both onUserLineBusy and onCallCancelled callbacks (callerId is your own ID)
    Unexpected interruption: The callee fails to receive the call and gets this callback (callerId is your own ID)
    TUICallKit.on(TUICallEvent.onCallCancelled, (res: any) => {
    console.log('onCallCancelled userId=' + res.callerId);
    });
    Parameter
    Type
    Description
    callerId
    String
    Caller ID (inviter)

    onCallBegin

    Indicates call connection. Both caller and called can receive it. You can start cloud recording, content review, etc., by listening to this event.
    TUICallKit.on(TUICallEvent.onCallBegin, (res: any) => {
    console.log('onCallBegin strRoomId=' + res.roomId.strRoomId + ', callMediaType=' + res.callMediaType + ',callRole=' + res.callRole);
    });
    Parameter
    Type
    Description
    roomId
    RoomId
    roomId.intRoomId: The audio and video room ID for this call (int type)
    roomId.strRoomId: The audio and video room ID for this call (String type)
    callMediaType
    Number
    Media Type of the call, Video Call, Voice Call
    params.callMediaType = 0:Voice Call
    params.callMediaType = 1:Video Call
    callRole
    Number
    Role, Enum Type: Caller, Called.
    params.callRole = 0: Unknown Type.
    params.callRole = 1: Caller (inviter).
    params.callRole = 2: Called (invitee).

    onCallEnd

    Indicates call disconnection. Both the caller and the called can receive it. You can listen to this event to display call duration, call type, etc., or to stop the cloud recording process.
    TUICallKit.on(TUICallEvent.onCallEnd, (res: any) => {
    console.log('onCallEnd strRoomId=' + res.roomId.strRoomId
    + ',callMediaType=' + res.callMediaType
    + ',callRole=' + res.callRole
    + ',totalTime=' + res.totalTime);
    });
    Parameter
    Type
    Description
    roomId
    RoomId
    roomId.intRoomId: The audio and video room ID for this call (int type)
    roomId.strRoomId: The audio and video room ID for this call (String type)
    callMediaType
    Number
    Media Type of the call, Video Call, Voice Call
    params.callMediaType = 0: Voice Call
    params.callMediaType = 1: Video Call
    callRole
    Number
    role, Enumeration Type: Caller, Called
    params.callRole = 0: Unknown Type.
    params.callRole = 1: Caller (inviter).
    params.callRole = 2: Called (invitee).
    totalTime
    Number
    The duration of this call, Unit: second

    onUserReject

    Callback for call rejection, in 1v1 calls, only the caller will receive the rejection callback; in group calls, all invitees can receive this callback.
    TUICallKit.on(TUICallEvent.onUserReject, (res: any) => {
    console.log('onUserReject userId=' + res.userId);
    });
    Parameter
    Type
    Description
    userId
    String
    ID of rejecting user

    onUserNoResponse

    Callback for no response from the other party.
    TUICallKit.on(TUICallEvent.onUserNoResponse, (res: any) => {
    console.log('onUserNoResponse userId=' + res.userId);
    });
    Parameter
    Type
    Description
    userId
    String
    User ID with no response

    onUserLineBusy

    Callback for call busy.
    TUICallKit.on(TUICallEvent.onUserLineBusy, (res: any) => {
    console.log('onUserLineBusy userId=' + res.userId);
    });
    Parameter
    Type
    Description
    userId
    String
    ID of rejecting user

    onUserJoin

    Callback for a user joining this call.
    TUICallKit.on(TUICallEvent.onUserJoin, (res: any) => {
    console.log('onUserJoin userId=' + res.userId);
    });
    Parameter
    Type
    Description
    userId
    String
    User ID joining the current call

    onUserLeave

    A user left the call.
    TUICallKit.on(TUICallEvent.onUserLeave, (res: any) => {
    console.log('onUserLeave userId=' + res.userId);
    });
    Parameter
    Type
    Description
    userId
    String
    The target userId

    onCallMediaTypeChanged

    Indicates a change in the call's media type.
    TUICallKit.on(TUICallEvent.onCallMediaTypeChanged, (res: any) => {
    console.log('onCallMediaTypeChanged oldCallMediaType=' + res.oldCallMediaType + ',newCallMediaType=' + res.newCallMediaType);
    });
    Parameter
    Type
    Description
    oldCallMediaType
    MediaType
    Previous call type
    newCallMediaType
    MediaType
    New call type

    onKickedOffline

    Current user kicked offline: You can notify the user on the UI and reinitialize.
    TUICallKit.on(TUICallEvent.onKickedOffline, (res: any) => {
    console.log('onKickedOffline');
    });

    onUserSigExpired

    Ticket expires when online: You need to generate a new userSig and reinitialize.
    TUICallKit.on(TUICallEvent.onUserSigExpired, (res: any) => {
    console.log('onUserSigExpired');
    });

    onUserVideoAvailable

    Whether a user is sending video.
    TUICallKit.on(TUICallEvent.onUserVideoAvailable, (res: any) => {
    console.log('onUserVideoAvailable userId=' + res.userId + 'isVideoAvailable=' + res.isVideoAvailable);
    });
    Parameter
    Type
    Description
    userId
    String
    The user ID.
    isVideoAvailable
    boolean
    Whether the user has video.

    onUserAudioAvailable

    Whether a user is sending audio.
    TUICallKit.on(TUICallEvent.onUserAudioAvailable, (res: any) => {
    console.log('onUserAudioAvailable userId=' + res.userId + 'isAudioAvailable=' + res.isAudioAvailable);
    });
    Parameter
    Type
    Description
    userId
    String
    The user ID.
    isAudioAvailable
    boolean
    Whether the user has audio.

    onUserVoiceVolumeChanged

    The volume levels of all users.
    TUICallKit.on(TUICallEvent.onUserVoiceVolumeChanged, (volumeMap: any) => {
    for (const [key, value] of volumeMap) {
    console.log(`onUserVoiceVolumeChanged userId: ${key}, volume: ${value}`);
    }
    });
    Parameter
    Type
    Description
    volumeMap
    any
    The volume table, which includes the volume of each user (userId). Value range: 0-100.

    onUserNetworkQualityChanged

    The network quality of all users.
    TUICallKit.on(TUICallEvent.onUserNetworkQualityChanged, (networkQuality: any) => {
    for (const [key, value] of networkQuality) {
    console.log(`onUserNetworkQualityChanged userId: ${key}, network quality: ${value}`);
    }
    });
    Parameter
    Type
    Description
    networkQuality
    any
    The key represents the userId, and the value represents the network quality of the user.
    value = Unknown
    value = Excellent
    value = Good
    value = Poor
    value = Bad
    value = Vbad
    value = Down
    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