📄 theapplication.java
字号:
package samples.mpccs.simpleprepaid;
import samples.fw.*;
import org.csapi.*;
import org.csapi.ui.*;
import org.csapi.cc.*;
import org.csapi.cc.mpccs.*;
/**
* This application crates a multiparty call to 4860034 and
* play a voice message after it is answered.
*/
public class TheApplication
{
static Object lock = new Object();
static TpAddress targetAddress = new TpAddress(
TpAddressPlan.P_ADDRESS_PLAN_E164,
"4860034",""
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;
static IpUICall ipUICall;
static IpUIManager ipUIMgr;
static IpAppUICall ipAppUICall;
static IpAppUIManager ipAppUIMgr;
static int uiCallSessionID;
public static void main(String[] argv) throws Exception
{
AppFWImpl.initiate("localhost", "12345", "FwInitial");
AppFWImpl.getAuthenticated("MPCCSApplication1");
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()));
IpInterface uiMgrIfc = AppFWImpl.getService("P_USER_INTERACTION");
ipUIMgr = org.csapi.ui.IpUIManagerHelper.narrow(
uiMgrIfc);
org.csapi.TpAddressRange destinationAddress =
new org.csapi.TpAddressRange(
TpAddressPlan.P_ADDRESS_PLAN_E164,
"8001234567", "0","0");
org.csapi.TpAddressRange originatingAddress =
new org.csapi.TpAddressRange(
TpAddressPlan.P_ADDRESS_PLAN_E164,
"*", "0", "0");
org.csapi.cc.TpCallNotificationScope scope =
new org.csapi.cc.TpCallNotificationScope(destinationAddress,
originatingAddress);
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_ADDRESS_COLLECTED,
addyCretieria,
org.csapi.cc.TpCallMonitorMode.P_CALL_MONITOR_MODE_INTERRUPT);
org.csapi.cc.TpCallNotificationRequest criteria =
new org.csapi.cc.TpCallNotificationRequest(scope,eventReqs);
int idAssignment = svcMgrs.ipMPCallCtlMgr.createNotification(
ipAppMPCallCtlMgr, criteria);
System.out.println("done to createNotification, and wating for reportNotification");
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 reportNotification(
org.csapi.cc.mpccs.TpMultiPartyCallIdentifier callReference,
org.csapi.cc.mpccs.TpCallLegIdentifier[] callLegReferenceSet,
org.csapi.cc.TpCallNotificationInfo notificationInfo,
int assignmentID)
{
try {
ipMPCall = callReference.CallReference;
callSessionID = callReference.CallSessionID;
ipCallLeg1 = callLegReferenceSet[0].CallLegReference;
legID1 = callLegReferenceSet[0].CallLegSessionID;
System.out.println("Start to createUICall");
org.csapi.ui.TpUITargetObject uiTargetObject = new org.csapi.ui.TpUITargetObject();
uiTargetObject.CallLeg(callLegReferenceSet[0]);
org.csapi.ui.TpUICallIdentifier retUICall = ipUIMgr.createUICall(
ipAppUICall,uiTargetObject);
ipUICall = retUICall.UICallRef;
uiCallSessionID = retUICall.UserInteractionSessionID;
TpUIInfo info = new TpUIInfo();
info.InfoData("Please into the number you want to call");
TpUIVariableInfo[] variableInfo = new TpUIVariableInfo[0];
TpUICollectCriteria colcri = new TpUICollectCriteria(1, 12, "#", -2, -2);
ipUICall.sendInfoAndCollectReq(uiCallSessionID, info,"ZH",variableInfo,colcri, 0);
System.out.println("message sent out, waiting it play out");
}
catch(Exception e){
e.printStackTrace();
}
}
public void sendInfoAndCollectRes(int userInteractionSessionID,
int assignmentID, org.csapi.ui.TpUIReport response,
String colInfo)
{
try
{
System.out.println("SendInfoAndCollectReq got UI res:"+response.value()+" collected:"+colInfo);
switch(response.value()) {
case TpUIReport._P_UI_REPORT_INFO_COLLECTED:
break;
default:
System.out.println("SendInfoAndCollectReq did not get, to quit");
ipUICall.release(userInteractionSessionID);
ipMPCall.release(callSessionID,org.csapi.cc.TpReleaseCause.from_int(0));
return;
}
org.csapi.cc.TpCallEventRequest[] eventReqs =
new org.csapi.cc.TpCallEventRequest[0];
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];
System.out.println("Start to create call leg for"+colInfo");
org.csapi.cc.mpccs.TpCallLegIdentifier newLeg =
ipMPCall.createCallLeg(callSessionID, ipAppCallLeg);
legID2 = newLeg.CallLegSessionID;
ipCallLeg2 = newLeg.CallLegReference;
System.out.println("done to create call leg for 4860034, to eventReportReq");
ipCallLeg2.eventReportReq(legID2,eventReqs);
System.out.println("done to eventReportReq, to route");
targetAddress.addrString = colInfo;
ipCallLeg2.route(legID2,targetAddress1,undefinedAddress,appInfo,
new org.csapi.cc.TpCallLegConnectionProperties(
org.csapi.cc.TpCallLegAttachMechanism.P_CALLLEG_ATTACH_EXPLICITLY));
System.out.println("done to route "+colInfo+", and wating for eventReportRes");
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void eventReportRes(int callLegSessionID,
org.csapi.cc.TpCallEventInfo eventInfo)
{
try {
if (eventInfo.CallEventType.value()!=TpCallEventType._P_CALL_EVENT_ANSWER) {
System.out.println("entered number not answer:"+eventInfo.CallEventType.value());
ipUICall.release(userInteractionSessionID);
ipMPCall.release(callSessionID,org.csapi.cc.TpReleaseCause.from_int(0));
return;
}
System.out.println("entered number answered, to release UI");
ipUICall.release(userInteractionSessionID);
System.out.println("and attachMedia of new leg");
ipCallLeg2.attachMediaReq(legID2);
ipMPCall.designCall(callSessionID);
}
catch(Exception e){
e.printStackTrace();
}
}
public void sendInfoAndCollectErrUICallProcess(
int userInteractionSessionID,
int assignmentID, org.csapi.ui.TpUIError error)
{
System.out.println("SendInfoAndCollectReq got error:"+ error.value()+", to quit");
try {
ipUICall.release(userInteractionSessionID);
ipMPCall.release(callSessionID,org.csapi.cc.TpReleaseCause.from_int(0));
}
catch(Exception e){
e.printStackTrace();
}
}
/*
public static void sendInfoErr(int uiSessionID, int assignmentID,
org.csapi.ui.TpUIError error)
{
System.out.println("SendInfoReq got error:"+ error.value()+", to quit");
try {
ipUICall.release(uiSessionID);
ipCall.release(callSessionID, org.csapi.cc.TpReleaseCause.from_int(0));
}
catch(Exception e){
e.printStackTrace();
}
synchronized(lock) {
try {
lock.notify();
}
catch(Exception e) {}
}
}
public void sendInfoResUICallProcess(Session session, org.csapi.ui.TpUIReport response)
{
try
{
System.out.println("SendInfoReq got UI res:"+response.value());
System.out.println("To Quit Alarm Call App");
// No matter what is the response, to clean up call
//
ipUICall.release(uiSessionID);
ipCall.release(callSessionID, org.csapi.cc.TpReleaseCause.from_int(0));
synchronized(lock) {
try {
lock.notify();
}
catch(Exception e) {}
}
}
catch(Exception e) {
e.printStackTrace();
}
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -