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

初始化

应用场景

在座席侧使用Openeye软电话接口进行注册话机号码时,需要完成组件初始化。

前提条件

  1. 已经完成WebDemo的下载。
  2. 已经安装Openeye的本地程序包,并且OpenEye的本地程序已经启动。
  3. 已经完成param.js中服务器等信息的配置。

流程说明

Demo中代码路径:WebDemo\js\OpenEye_SDK.js。

  1. 初始化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");
    }

  2. 初始化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.");
          }
      
      }

相关文档