更新时间:2024-08-22 GMT+08:00
分享

接听呼叫

应用场景

座席侧收到OpenEye上报的呼入事件后,自动调用接听呼叫接口,实现来话的接听。

前提条件

流程说明

调用OpenEyeCall的acceptCall接口进行接听呼叫。
/**
 * 来电事件
 **/
function onCallIncoming(data) { 
    //记录一下来电的callid,后续接听接口需要用到该参数
    var tupCurrentCallId = data.param.call_id;

    //此处调用仅是演示如何调用接听呼叫接口,实际开发中请根据需要在合适地方调用该接口
    acceptCall(tupCurrentCallId); 
} 
/** 
 * 接听呼叫 
 */ 
function acceptCall(tupCurrentCallId) { 
   if (tupCurrentCallStatus == OPENEYE_CALL_STATUS.ALERTING) {
        this.global_openEye_SDK.openEyeCall.acceptCall(tupCurrentCallId, tupCurrentCallType, { response: onAcceptCallReponse });
    } else {
        console.error("Phone status is invalid. Now it's " + tupCurrentCallStatus);
        alert("Phone status is invalid. Now it's " + tupCurrentCallStatus);
    }
} 
/** 
 * 接听接口的响应 
 */
function onAcceptCallReponse(data) { 
    if (data.result == 0) {
        console.error("AcceptCall success. ");
    } else {
        console.error("AcceptCall failed. The ErrorCode is " + data.result);
        console.info(data);
        alert("AcceptCall failed.  The ErrorCode is " + data.result);
    }
}

相关文档