初始化
应用场景
在座席侧使用Openeye软电话接口进行注册话机号码时,需要完成组件初始化。
前提条件
- 已经完成WebDemo的下载。
- 已经安装Openeye的本地程序包,并且OpenEye的本地程序已经启动。
- 已经完成param.js中服务器等信息的配置。
流程说明
![](https://support.huaweicloud.com/devg-openeye-cec/public_sys-resources/note_3.0-zh-cn.png)
Demo中代码路径:WebDemo\js\OpenEye_SDK.js。
- 初始化SDK。
打开webdemo页面,会收到OpenEye返回的消息,只有收到onOpeneyeLoginReady后才能调用OpeneyeLogin下的接口,只有收到onOpeneyeCallReady后才能调用OpeneyeCall下的接口。
function initOpeneye(){ if (global_openEye_SDK== null) { global_openEye_SDK = new OpenEye_SDK({ onOpeneyeDeamonReady: onOpeneyeDeamonReady, onOpeneyeDeamonClose: onOpeneyeDeamonClose, serviceStartUp: serviceStartUp, serviceShutDown: serviceShutDown, onOpeneyeLoginReady: onOpeneyeLoginReady, onOpeneyeLoginClose: onOpeneyeLoginClose, onOpeneyeCallReady: onOpeneyeCallReady, onOpeneyeCallClose: onOpeneyeCallClose, onVersionInfoNotify : onVersionInfoNotify }); } } function onVersionInfoNotify(data) { writeLog("version is " + data.param.version); } function onOpeneyeDeamonReady() { writeLog("OpenEye Deamon is Ready"); } function onOpeneyeDeamonClose() { writeLog("OpenEye Deamon is Closed, please restart OpenEye Deamon it."); global_openEye_SDK= null; } function serviceStartUp() { writeLog("Openeye Service StartUp"); } function serviceShutDown() { writeLog("Openeye Service is shutdown, please restart it."); } function onOpeneyeLoginReady(){ writeLog("onOpeneyeLoginReady"); } function onOpeneyeLoginClose(){ writeLog("onOpeneyeLoginClose"); } function onOpeneyeCallClose() { writeLog("onOpeneyeCallClose"); } function onOpeneyeCallReady() { writeLog("onOpeneyeCallReady"); }
- 初始化OpenEyeCall的参数和监听呼叫事件。
function initOpeneyeCall(localIp) { console.info("onOpeneyeCallReady"); initOpeneyeCall(); }
- 调用setBasicCallEvent接口监听的OpenEyeCall的呼叫事件。
function initOpeneyeCall() { global_openEye_SDK.openEyeCall.setBasicCallEvent({ onCallIncoming: onCallIncoming, onCallOutGoing: onCallOutGoing, onCallRingBack: onCallRingBack, onCallConnected: onCallConnected, onCallEnded: onCallEnded, onCallEndedFailed: onCallEndedFailed, onCallRtpCreated: onCallRtpCreated, onCallOpenVideoReq: onCallOpenVideoReq }); }
- 调用config接口设置OpenEyeCall的SIP服务器信息。
必须保证SIP服务器的信息填写正确,否则无法进行账号注册
function sipBasicCfg() { global_cloudIPCC_SDK.openEyeCall.config({ networkInfo: { serverAddr: GlobalSipIp, sipServerPort: GlobalSipPort, sipTransportMode: 0, httpPort: 0 }, }, {response: configResponse}); } function configResponse(data) { if (data.result == 0) { writeLog("Set OpenEyeCall Sip Config Success."); register(); } else { writeLog("Set OpenEyeCall Sip Config Failed."); } }
- 调用setBasicCallEvent接口监听的OpenEyeCall的呼叫事件。