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. |
// Import TCCC-related packageimport {TcccWorkstation,TCCCLoginType,TCCCAudioRoute,TCCCEndReason} from "tccc-sdk-uniapp";// Create an instance and set an event callbackconst tcccSDK = TCCCWorkstation.sharedInstance();// Error event callbacktcccSDK.on('onError',(errCode,errMsg) => {});// Call end callbacktcccSDK.on('onEnded',(reason,reasonMessage,sessionId) => {if (reason == TCCCEndReason.Error) {// Call exception}});// Peer answer callbacktcccSDK.on('onAccepted',(sessionId) => {});// Release all event callback monitoringtcccSDK.off('*');
API | Description |
login | SDK login |
checkLogin | Checks SDK login status. It is recommended to call when the page onShow . |
logout | SDK logout |
// For how to obtain sdkAppId, userId, and token, see the corresponding fields in Key Concepts.// Agent logintcccSDK.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}});
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 |
// Initiate a calltcccSDK.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 calltcccSDK.terminate();// Answer the calltcccSDK.answer((code,message) => {if (code == TcccErrorCode.ERR_NONE) {// Answer succeeded} else {// Answer failed}});
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 speakerconst route = TCCCAudioRoute.Speakerphone;tcccSDK.getDeviceManager().setAudioRoute(route);
API | Description |
getSDKVersion | Obtains the SDK version. |
setLogLevel | Sets the log output level. |
setConsoleEnabled | Enables/Disables console log print. |
// Obtain SDK version numberTCCCWorkstation.getSDKVersion();
API | Description |
onError | Error event callback |
onWarning | Warning event callback |
// Error event callbacktcccSDK.on('onError',(errCode,errMsg) => {});// Warning event callbacktcccSDK.on('onWarning',(warningCode,warningMsg) => {});
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 |
// Session end eventtcccSDK.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 callstcccSDK.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 answeredtcccSDK.on('onAccepted',(sessionId) => {});// Real-time statistics callback of network qualitytcccSDK.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 soundtcccSDK.on('onAudioVolume',(userId,volume) => {});
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. |
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});
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. |
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 |
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 |
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. |
Was this page helpful?