tencent cloud

Feedback

Last updated: 2024-04-01 17:50:44

    API Overview

    Creating Instances and Event Callbacks

    API
    Description
    sharedInstance
    Creates a TCCCWorkstation instance (singleton).
    destroyInstance
    Destroys a TCCCWorkstation instance (singleton). It is recommended to uninstall the TCCCWorkstation instance when it is not in use.
    on
    Sets a TCCCWorkstation event callback.
    off
    Cancels a TCCCWorkstation event callback.

    Sample Code for Creating Instances and Setting Event Callbacks

    // Import TCCC-related package
    import {TcccWorkstation,TCCCLoginType,TCCCAudioRoute,TCCCEndReason} from "tccc-sdk-uniapp";
    // Create an instance and set an event callback
    const tcccSDK = TCCCWorkstation.sharedInstance();
    // Error event callback
    tcccSDK.on('onError',(errCode,errMsg) => {
    });
    // Call end callback
    tcccSDK.on('onEnded',(reason,reasonMessage,sessionId) => {
    if (reason == TCCCEndReason.Error) {
    // Call exception
    }
    });
    // Peer answer callback
    tcccSDK.on('onAccepted',(sessionId) => {
    });
    // Release all event callback monitoring
    tcccSDK.off('*');

    Login API Functions

    API
    Description
    login
    SDK login
    checkLogin
    Checks SDK login status. It is recommended to call when the page onShow .
    logout
    SDK logout

    Login Sample Code

    // For how to obtain sdkAppId, userId, and token, see the corresponding fields in Key Concepts.
    // Agent login
    tcccSDK.login({
    sdkAppID: sdkAppId,
    userId: userID,
    token: token,
    type: type,
    }, (code,message) => {
    if (code == TcccErrorCode.ERR_NONE) {
    // Login succeeded
    } else {
    // Login failed
    }
    });
    // When the mobile application is switched to the background, the operating system will pause the application's process to save resources. We recommend that you do a login status check at the onShow.
    tcccSDK.checkLogin(code,message) => {
    if (code == TcccErrorCode.ERR_NONE) {
    // Logged in
    } else {
    // Not logged in
    }
    });

    Call-related API Functions

    API
    Description
    call
    Initiates a call
    answer
    Answers the inbound call
    terminate
    Ends the call
    sendDTMF
    Sends Dual-Tone Multi-Frequency (DTMF) signals
    mute
    Mutes.
    unmute
    Unmutes.
    startPlayMusic
    Starts playing music
    stopPlayMusic
    Stops playing music

    Sample Code for Initiating and Ending a Call

    // Initiate a call
    tcccSDK.call({
    to: '134xxxx', // Contact number (required)
    remark: "xxx", // Number remarks, which will replace the number displayed in the call bar (optional)
    uui: "xxxx", // User-defined data (optional)
    }, (code,message) => {
    if (code == TcccErrorCode.ERR_NONE) {
    // Initiation succeeded
    } else {
    // Initiation failed
    }
    });
    
    // End the call
    tcccSDK.terminate();
    // Answer the call
    tcccSDK.answer((code,message) => {
    if (code == TcccErrorCode.ERR_NONE) {
    // Answer succeeded
    } else {
    // Answer failed
    }
    });

    Audio Device API Functions

    API
    Description
    setAudioCaptureVolume
    Sets the local audio capture volume.
    getAudioCaptureVolume
    Obtains the local audio capture volume.
    setAudioPlayoutVolume
    Sets the remote audio playback volume.
    getAudioPlayoutVolume
    Obtains the remote audio playback volume.
    setAudioRoute
    Sets audio routing.
    // TCCCAudioRoute.Earpiece is an earphone
    // Set as a speaker
    const route = TCCCAudioRoute.Speakerphone;
    tcccSDK.getDeviceManager().setAudioRoute(route);

    Debugging APIs

    API
    Description
    getSDKVersion
    Obtains the SDK version.
    setLogLevel
    Sets the log output level.
    setConsoleEnabled
    Enables/Disables console log print.

    Sample Code for Obtaining SDK Version

    // Obtain SDK version number
    TCCCWorkstation.getSDKVersion();

    Error and Warning Events

    API
    Description
    onError
    Error event callback
    onWarning
    Warning event callback

    Sample Code for Handling Error Event Callbacks

    // Error event callback
    tcccSDK.on('onError',(errCode,errMsg) => {
    });
    // Warning event callback
    tcccSDK.on('onWarning',(warningCode,warningMsg) => {
    });

    Call Event Callback

    API
    Description
    onNewSession
    New session event, including inbound and outbound calls
    onAccepted
    Peer answer callback
    onEnded
    Session End Event
    onAudioVolume
    Callback for volume feedback
    onNetworkQuality
    Real-time statistics callback of network quality

    Sample Code for Answer and Agent Hang-up Event Callbacks

    // Session end event
    tcccSDK.on("onEnded",(reason,reasonMessage,sessionId) => {
    var msg = reasonMessage;
    if (reason == TCCCEndReason.Error) {
    msg = "System exception "+reasonMessage;
    } else if (reason == TCCCEndReason.Timeout) {
    msg = "Timeout hang-up";
    } else if (reason == TCCCEndReason.LocalBye) {
    msg = "You hung up";
    } else if (reason == TCCCEndReason.RemoteBye) {
    msg = "The other party has hung up";
    } else if (reason == TCCCEndReason.Rejected) {
    msg = "The other party has rejected";
    } else if (reason == TCCCEndReason.RemoteCancel) {
    msg = "The other party has cancelled";
    }
    });
    // New session event, including inbound and outbound calls
    tcccSDK.on('onNewSession',(res) => {
    const sessionDirection = res.sessionDirection;
    if (sessionDirection == TCCCSessionDirection.CallIn) {
    // Inbound call. You cannot receive this event when the phone switches to the background, so we recommend that you enable answering calls on your mobile phone
    } else if (sessionDirection == TCCCSessionDirection.CallOut){
    // Outbound call
    }
    });
    // The other party has answered
    tcccSDK.on('onAccepted',(sessionId) => {
    });
    // Real-time statistics callback of network quality
    tcccSDK.on('onNetworkQuality',(localQuality) => {
    const quality = localQuality.quality;
    // Current network is average
    // TCCCQuality_Poor = 3,
    // Current network is poor
    // TCCCQuality_Bad = 4,
    // Current network is very poor
    // TCCCQuality_Vbad = 5,
    // The current network does not meet the minimum requirements for calls
    // TCCCQuality_Down = 6,
    
    });
    // Callback for volume feedback. Volume is from 0 to 100, and a larger value indicates louder sound
    tcccSDK.on('onAudioVolume',(userId,volume) => {
    
    });

    Event Callback of Connection with Cloud

    API
    Description
    onConnectionLost
    The connection between the SDK and the cloud has been disconnected.
    onTryToReconnect
    The SDK is trying to reconnect to the cloud.
    onConnectionRecovery
    The connection between the SDK and the cloud has been restored.

    Sample Code for Event Callback of Connection with Cloud

    tcccSDK.on('onConnectionLost',(serverType) => {
    // The connection with the cloud has been disconnected
    });
    tcccSDK.on('onTryToReconnect',(serverType) => {
    // Trying to reconnect to the cloud
    });
    tcccSDK.on('onConnectionRecovery',(serverType) => {
    // The connection with the cloud has been restored
    });

    API Error Codes

    Basic Error Codes

    Symbol
    Value
    Meaning
    ERR_NONE
    0
    No error. Succeeded.
    ERR_HTTP_REQUEST_FAILURE
    -10001
    HTTP request failed. Please check your network connection.
    ERR_HTTP_TOKEN_ERROR
    -10002
    The token login ticket is incorrect or has expired.
    ERR_HTTP_GETSIPINFO_ERROR
    -10003
    Failed to obtain the agent configuration. Please contact us.
    ERR_NETWORK_CANNOT_RESET
    -10004
    In a call. Network reset and outbound call are prohibited.
    ERR_HAD_LOGGEDOUT
    -10005
    You have already logged out. Please log in again.
    ERR_UNRIGIST_FAILURE
    20001
    Failed to deregister.
    ERR_ANSWER_FAILURE
    20002
    Failed to answer the call, usually because the TRTC failed to enter the room.
    ERR_SIPURI_WRONGFORMAT
    20003
    URI format error.

    SIP Error Codes

    Symbol
    Value
    Meaning
    ERR_SIP_BAD_REQUEST
    400
    Error request, usually because the agent initiates a request without logging in
    ERR_SIP_UNAUTHORIZED
    401
    Unauthorized (username or password is incorrect)
    ERR_SIP_PAYMENTREQUIRED
    402
    Payment required, typically when the agent's license is full
    ERR_SIP_FORBIDDEN
    403
    Incorrect password, or has been kicked out
    ERR_SIP_REQUESTTIMEOUT
    408
    Request timeout (network timeout)
    ERR_SIP_REQUEST_TERMINATED
    487
    Request termination (network error, in case of network interruption)
    ERR_SIP_SERVICE_UNAVAILABLE
    503
    Service unavailable
    ERR_SIP_SERVER_TIMEOUT
    504
    Service timeout

    Audio Device Error Codes

    Symbol
    Value
    Meaning
    ERR_MIC_START_FAIL
    -1302
    Failed to start the microphone. The device's microphone configuration program (driver) is abnormal. Please disable and re-enable the device, restart the device, or update the configuration program.
    ERR_MIC_NOT_AUTHORIZED
    -1317
    No access to the microphone. This usually occurs on mobile devices and may be because the user denied the access.
    ERR_MIC_SET_PARAM_FAIL
    -1318
    Failed to set microphone parameters.
    ERR_MIC_OCCUPY
    -1319
    The microphone is occupied. This occurs when, for example, the user is currently having a call on the mobile device.
    ERR_MIC_STOP_FAIL
    -1320
    Failed to stop the microphone.
    ERR_SPEAKER_START_FAIL
    -1321
    Failed to start the speaker, for example, on Windows or Mac.
    ERR_SPEAKER_SET_PARAM_FAIL
    -1322
    Failed to set speaker parameters.
    ERR_SPEAKER_STOP_FAIL
    -1323
    Failed to stop the speaker.
    ERR_UNSUPPORTED_SAMPLERATE
    -1306
    Unsupported audio sample rate

    Network Error Codes

    Symbol
    Value
    Meaning
    ERR_RTC_ENTER_ROOM_FAILED
    -3301
    Failed to enter the room. Please view -3301 in onError to confirm the message for the reason of the failure.
    ERR_RTC_REQUEST_IP_TIMEOUT
    -3307
    Request for IP and Sig timed out. Please check whether your network is functioning properly and whether UDP is unblocked in your network firewall.
    ERR_RTC_CONNECT_SERVER_TIMEOUT
    -3308
    Request for room entry timed out. Please check your network connection or whether you are on a VPN. You can also try switching to 4G for confirmation.
    ERR_RTC_ENTER_ROOM_REFUSED
    -3340
    Room entry request was denied. Please check whether you are continually calling enterRoom to enter the room of the same ID.
    
    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