⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 theapplication.java

📁 中兴公司在parlayx开发方面的培训文档
💻 JAVA
字号:
package samples.mpccs.createcallleg;


import samples.fw.*;
import org.csapi.*;
import org.csapi.cc.*;
import org.csapi.cc.mpccs.*;

/**
 * This application creates multiparty call and 
 * bridges two parties 4860034 and 4860037
 * with explicit call leg handling.
 */
 
public class TheApplication
{
    static Object lock = new Object();
    
    static  TpAddress targetAddress1 = new TpAddress(
			TpAddressPlan.P_ADDRESS_PLAN_E164,
            "4860034",""
			TpAddressPresentation.P_ADDRESS_PRESENTATION_UNDEFINED,
       		      TpAddressScreening.P_ADDRESS_SCREENING_USER_NOT_VERIFIED,
			"A");
    static TpAddress origAddress2 = new TpAddress(
			TpAddressPlan.P_ADDRESS_PLAN_E164,
            "4860037","",
			TpAddressPresentation.P_ADDRESS_PRESENTATION_UNDEFINED,
       		      TpAddressScreening.P_ADDRESS_SCREENING_USER_NOT_VERIFIED,
			"A");
    static TpAddress undefinedAddress = new TpAddress(
			TpAddressPlan.P_ADDRESS_PLAN_E164,
            "1","",
			TpAddressPresentation.P_ADDRESS_PRESENTATION_UNDEFINED,
       		      TpAddressScreening.P_ADDRESS_SCREENING_USER_NOT_VERIFIED,
			"A");

	static IpMuiltpartyCall ipMPCall;
	static IpMuiltpartyCallControlManager ipMPCallCtlMgr;
	static IpAppMuiltpartyCallControlManager ipAppMPCallCtlMgr;
	static int callSessionID;
	
	static IpCallLeg ipCallLeg1, ipCallLeg2;
	static int legID1, legID2;
	static IpAppCallLeg ipAppCallLeg;
	
    public static void main(String[] argv) throws Exception
    {
		AppFWImpl.initiate("localhost", "12345", "FwInitial");
		AppFWImpl.getAuthenticated("MPCCSApplication3");
		
		IpInterface mgrIfc = AppFWImpl.getService("P_MULTIPARTY_CALL_CONTROL");
		
		ipMPCallCtlMgr = org.csapi.cc.mpccs.IpMuiltpartyCallControlManagerHelper.narrow(
                                  mgrIfc);
		ipAppMPCallCtlMgr = IpAppMuiltpartyCallControlManagerHelper.narrow(
                AppFWImpl.poa.servant_to_reference(
                           new AppMPCallControlManagerImpl()));
    	
    	TpMultiPartyCallIdentifier retCall =
    			ipMPCallCtlMgr.createCall(ipAppMPCallCtlMgr);
    			
		ipMPCall = retCall.CallReference;
		callSessionID = retCall.CallSessionID;

        org.csapi.cc.TpCallEventRequest[] eventReqs =
          new org.csapi.cc.TpCallEventRequest[1];

        org.csapi.cc.TpAdditionalCallEventCriteria addyCretieria =
            new  org.csapi.cc.TpAdditionalCallEventCriteria();
        addyCretieria.Dummy((short) 0);
        eventReqs[0] = new org.csapi.cc.TpCallEventRequest(
          org.csapi.cc.TpCallEventType.P_CALL_EVENT_ANSWER ,
          addyCretieria,
          org.csapi.cc.TpCallMonitorMode.from_int(0));
        org.csapi.cc.TpCallAppInfo[] appInfo = new org.csapi.cc.TpCallAppInfo[0];
		
		ipAppCallLeg = IpAppCallLegHelper.narrow(
			AppFWImpl.poa.servant_to_reference(new AppCallLegImpl());

        System.out.println("Start to create call leg for 4860034");
		org.csapi.cc.mpccs.TpCallLegIdentifier newLeg1 =  
			ipMPCall.createCallLeg(callSessionID, ipAppCallLeg);
        legID1 = newLeg1.CallLegSessionID;
        ipCallLeg1 = newLeg1.CallLegReference;
        System.out.println("done to create call leg for 4860034, to eventReportReq");
        
        ipCallLeg1.eventReportReq(legID1,eventReqs);
        System.out.println("done to eventReportReq, to route");

        ipCallLeg1.route(legID1,targetAddress1,undefinedAddress,appInfo,
            new org.csapi.cc.TpCallLegConnectionProperties(
              org.csapi.cc.TpCallLegAttachMechanism.P_CALLLEG_ATTACH_IMPLICITLY));
        System.out.println("done to route 4860034, and wating for eventReportRes");


        System.out.println("Start to create call leg for 4860037");
		org.csapi.cc.mpccs.TpCallLegIdentifier newLeg2 =  
			ipMPCall.createCallLeg(callSessionID, ipAppCallLeg);
        legID2 = newLeg2.CallLegSessionID;
        ipCallLeg2 = newLeg2.CallLegReference;
        System.out.println("done to create call leg for 4860037, to eventReportReq");
        
        ipCallLeg2.eventReportReq(legID2,eventReqs);
        System.out.println("done to eventReportReq, to route");

        ipCallLeg2.route(legID2, targetAddress2,undefinedAddress,appInfo,
            new org.csapi.cc.TpCallLegConnectionProperties(
              org.csapi.cc.TpCallLegAttachMechanism.P_CALLLEG_ATTACH_EXPLICITLY));
        System.out.println("done to route 4860037, and wating for eventReportRes");

        synchronized(lock) {
          try {
            lock.wait();
          }
          catch(Exception e) {}
          System.out.println("TheApplication finished");
        }
    }

    static public void callEnded(int SessionID, org.csapi.cc.gccs.TpCallEndedReport report)
    {
      try {
      	ipMPCall.release(callSessionID,org.csapi.cc.TpReleaseCause.from_int(0));
      }
      catch(Exception e){}
      synchronized(lock) {
        try {
          lock.notify();
        }
        catch(Exception e) {}
      }
    }
    
	public static void eventReportRes(int callLegSessionID,
			org.csapi.cc.TpCallEventInfo eventInfo)
	{
      if (eventInfo.CallEventType.value()!=TpCallEventType._P_CALL_EVENT_ANSWER) {
      	 if (callLegSessionID==legID1)
      	 	System.out.println("4860034 is not answer:"+eventInfo.CallEventType.value());
      	 else
      	 	System.out.println("4860037 is not answer:"+eventInfo.CallEventType.value());
      }
      if (callLegSessionID==legID2) {
      	ipCallLeg2.attachMediaReq(legID2);
      }
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -