更新时间:2023-10-12 GMT+08:00

账号注册

应用场景

注册座席的话机。

前提条件

已经完成OpenEyeCall参数的初始化,并且SIP服务器信息填写正确。

流程说明

调用OpenEyeCall的register接口进行接听呼叫。

  • 调用注册接口除了需要处理返回结果,还需要监听onRegStatusUpdate事件。
  • 注册是一个异步的过程,并不是注册返回结果是0就表示注册成功,还需要看onRegStatusUpdate的返回参数register_state是否为3,只有为3才表示成功。
/**
 * 注册
 */
function register() { 
    var phoneNumber = document.getElementById("phoneNumber").value;
    var password = document.getElementById("password").value;
    userPhoneNumber = phoneNumber + "@" + GlobalSipIp;//OpenEyeConfig.domain;
	console.info("register info="+userPhoneNumber);

	var sipMode=1;
	if(EnablePoolMode){
		sipMode=1;
	}
    this.global_openEye_SDK.openEyeCall.register(userPhoneNumber, phoneNumber, password, sipMode, {
        onRegStatusUpdate: onRegStatusUpdate,
        onForceUnReg: onForceUnRegInfo,
        response: registerResponse
    });
} 
/**
 * 注册结果
 * @param {*} data 
 */
function registerResponse(data) { 
   if (data.result == 0) {
        console.info("Register Operation Success");
	getMediaDevices();
    } else {
        console.error("Register Operation Failed");
        console.error(data);
    }

} 

/**
 * 注册结果上报
 * @param {*} data 
 */
function onRegStatusUpdate(data) { 
    var userNumber = data.param.user_number;
    var state = ["unregister", "registering", "deregistering", "registered", "deregistered"];
    var reason = data.param.reason_code; //complete reason code refer to: http://blog.csdn.net/kafeiwuzhuren/article/details/7242791    
    if (reason == 403) {
        console.log("403:forbidden");
    }
    if (reason == 408) {
        console.log("408:request overtime");
    }
    var currentState = state[data.param.register_state];
    var obj = { userNum: userNumber, stateInfo: currentState, reasonInfo: reason }
    console.log("onRegStatusUpdate");
    console.log(data);
    document.getElementById("phoneStatus").innerText = obj.stateInfo;
    if (data.param.register_state == 3) {
        document.getElementById("voiceControlDiv").style.visibility = "visible";
    }
	if(data.notify==1004){
		document.getElementById("phoneStatus").innerText = "登录成功";
		document.getElementById("voiceControlDiv").style.visibility = "visible";
	}

} 

function onForceUnRegInfo(data) { 
    document.getElementById("phoneStatus").innerText = "DeRegister";
    document.getElementById("voiceControlDiv").style.visibility = "hidden";
    userPhoneNumber = "";
    tupCurrentCallId = "";
    console.log("onForceUnRegInfo");
    console.log(data);

}