tencent cloud

Feedback

Last updated: 2024-04-01 17:51:12

    Creating Instances and Event Callbacks

    API
    Description
    Creates a TCCCWorkstation instance (singleton).
    Destroys a TCCCWorkstation instance (singleton).
    Sets a TCCCWorkstation event callback.

    Sample Code for Creating Instances and Setting Event Callbacks

    // Create an instance and set an event callback
    TCCCWorkstation tcccSDK = TCCCWorkstation.sharedInstance(getApplicationContext());
    tcccSDK.setListener(new TCCCListener() {});

    Login API Functions

    API
    Description
    SDK login
    Checks whether the SDK is already logged in.
    SDK logout

    Login Sample Code

    TCCCTypeDef.TCCCLoginParams loginParams = new TCCCTypeDef.TCCCLoginParams();
    /// The agent ID for login, which is usually an email address
    loginParams.userId = "";
    /// The login ticket, required for the Agent login mode. For details, see Creating SDK Login.
    /// Token](https://www.tencentcloud.com/document/product/679/49227?from_cn_redirect=1)
    loginParams.token = "";
    /// Cloud Contact Center application ID, which usually starts with 1400
    loginParams.sdkAppId = 0;
    // Must be the Agent mode
    loginParams.type = TCCCTypeDef.TCCCLoginType.Agent;
    
    tcccSDK.login(loginParams, new TXCallback() {
    @Override
    public void onSuccess() {
    // login success
    }
    
    @Override
    public void onError(int code, String desc) {
    // login error
    }
    });

    Call-related API Functions

    API
    Description
    Initiates a call
    Answers the inbound call
    Ends the call
    Sends Dual-Tone Multi-Frequency (DTMF) signals
    Mutes.
    Unmutes.

    Sample Code for Initiating and Ending a Call

    TCCCTypeDef.TCCCStartCallParams callParams =new TCCCTypeDef.TCCCStartCallParams();
    //Format <scheme> : <user> @<host>, such as sip:1343xxxx@1400xxxx.tccc.qcloud.com, where 1343xxxx is a mobile phone number, and 1400xxxx is your TCCC application ID
    callParams.to = "sip:1343xxxx@1400xxxx.tccc.qcloud.com";
    // Initiate a call
    tcccSDK.call(callParams, new TXCallback() {
    @Override
    public void onSuccess() {
    // call success
    }
    
    @Override
    public void onError(int code, String desc) {
    // call error
    }
    });
    // End the call
    tcccSDK.terminate();

    Audio Device API Functions

    API
    Description
    Sets the local audio capture volume.
    Obtains the local audio capture volume.
    Sets the remote audio playback volume.
    Obtains the remote audio playback volume.
    Sets audio routing.

    Debugging APIs

    API
    Description
    Obtains the SDK version.
    Sets the log output level.
    Enables/Disables console log print.
    Calls an experimental API.

    Sample Code for Obtaining SDK Version

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

    Error and Warning Events

    API
    Description
    Error event callback
    Warning event callback

    Sample Code for Handling Error Event Callbacks

    tcccSDK.setListener(new TCCCListener() {
    /**
    * Error event callback
    * Error event, indicating that the SDK encounters an irrecoverable error, such as a failure of entering a room or a device startup failure
    * @param errCode //Error code
    * @param errMsg //Error message
    * @param extraInfo Additional information field. Some error codes may carry additional information to help locate problems.
    */
    @Override
    public void onError(int errCode, String errMsg, Bundle extraInfo) {
    super.onError(errCode, errMsg, extraInfo);
    }
    
    /**
    * Warning event callback
    * Warning event, indicating advisory issues thrown by the SDK, such as audio lag or high CPU utilization
    * @param warningCode Warning code
    * @param warningMsg Warning message
    * @param extraInfo Additional information field. Some warning codes may carry additional information to help locate problems.
    */
    @Override
    public void onWarning(int warningCode, String warningMsg, Bundle extraInfo) {
    super.onWarning(warningCode, warningMsg, extraInfo);
    }
    });

    Call Event Callback

    API
    Description
    New session event, including inbound and outbound calls
    Session End Event
    Callback for volume feedback
    Real-time statistics callback of network quality

    Sample Code for Answer and Agent Hang-up Event Callbacks

    tcccSDK.setListener(new TCCCListener() {
    @Override
    public void onNewSession(TCCCTypeDef.ITCCCSessionInfo info) {
    super.onNewSession(info);
    // New session event, including inbound and outbound calls. The direction can be determined through info.sessionDirection
    }
    
    @Override
    public void onEnded(int reason, String reasonMessage, String sessionId) {
    super.onEnded(reason, reasonMessage, sessionId);
    // End of session
    }
    
    @Override
    public void onAccepted(String sessionId) {
    super.onAccepted(sessionId);
    // Counterpart answers
    }
    });

    Event Callback of Connection with Cloud

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

    Sample Code for Event Callback of Connection with Cloud

    tcccSDK.setListener(new TCCCListener() {
    /**
    * The connection between the SDK and the cloud has been disconnected.
    * The SDK will issue this callback when its connection with the cloud is disconnected. The primary causes for the disconnection include the network being unavailable or a network switch.
    * For example, this event may occur when the user enters an elevator during a call. After this event is thrown, the SDK will attempt to re-establish a connection with the cloud.
    * During the reconnection process, onTryToReconnect will be thrown, and onConnectionRecovery will be thrown after the connection is restored.
    * Therefore, the SDK switches between the following three connection-related events in the following order:
    */
    @Override
    public void onConnectionLost(TCCCServerType serverType) {
    super.onConnectionLost(serverType);
    }
    
    /**
    * The SDK is trying to reconnect to the cloud
    * When the SDK's connection with the cloud is lost, it will throw onConnectionLost, after which it will strive to re-establish a connection with the cloud and throw this event.
    * After the connection is restored, onConnectionRecovery is thrown.
    */
    @Override
    public void onTryToReconnect(TCCCServerType serverType) {
    super.onTryToReconnect(serverType);
    }
    
    /**
    * The connection between the SDK and the cloud has been restored.
    * When the SDK's connection with the cloud is lost, it throws onConnectionLost, and then tries to re-establish a connection with the cloud and throws onTryToReconnect.
    * This callback is thrown when the connection is restored.
    */
    @Override
    public void onConnectionRecovery(TCCCServerType serverType) {
    super.onConnectionRecovery(serverType);
    }
    });
    

    API Error Codes

    Basic Error Codes

    Symbol
    Value
    Meaning
    ERR_SIP_SUCCESS
    200
    Execution succeeded.
    ERR_UNRIGIST_FAILURE
    20001
    Login failed.
    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
    ERR_SIP_UNAUTHORIZED
    401
    Unauthorized (username or password is incorrect)
    ERR_SIP_AUTHENTICATION_REQUIRED
    407
    Proxy authentication required. Please check whether the login API has been called.
    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