我目前正在使用map-api-2.1.0.jar和map-impl-2.1.0.jar来处理来自手机的 USSD 字符串。这工作正常,用户正在接收 USSD 响应。
地图处理类
public class MapHandling implements MAPDialogListener,MAPServiceSmsListener,MAPServiceMobilityListener,MAPServiceCallHandlingListener,MAPSer viceSupplementaryListener{
@Override
public void onProcessUnstructuredSSRequest(ProcessUnstructuredSSRequest procUnstrReqInd)
{
try
{
logger.debug("dialogId: " +procUnstrReqInd.getMAPDialog().getLocalDialogId() + " USSD String:"+procUnstrReqInd.getUSSDString()+"MSISDN:"+procUnstrReqInd.getMAPDialog().getReceivedDestReference().getAddress());
} catch (Exception exp)
{
logger.error("USSD - error while loging ussd data ", exp);
}
ss7.request.UnstructuredSSRequest ussdRequest = new ss7.request.UnstructuredSSRequest(procUnstrReqInd);
Thread thr = new Thread(ussdRequest);
thr.start();
}
}
ss7.request.UnstructuredSSRequest 类
public class UnstructuredSSRequest extends SS7Operation implements Runnable {
ProcessUnstructuredSSRequest procUnstrReqInd;
public UnstructuredSSRequest(ProcessUnstructuredSSRequest procUnstrReqInd) {
this.procUnstrReqInd = procUnstrReqInd;
}
@Override
public void run() {
logger.debug("[" + refId + "] Sending USSD response");
sendUSSDResponse(validRequest);
}
private void sendUSSDResponse(boolean validRequest) {
MAPDialogSupplementary dialog = procUnstrReqInd.getMAPDialog();
USSDString ussdStrObj = MapProvider.getMAPParameterFactory().createUSSDString("Thank you for using CC service!");
dialog.addProcessUnstructuredSSResponse(procUnstrReqInd.getInvokeId(),procUnstrReqInd.getDataCodingScheme(), ussdStrObj);
dialog.close(false);
dialog.release();
}
}
上面的代码运行良好,我收到“感谢您使用 CC 服务!” 当我从手机拨打 USSD 时响应。 我想将其更改为交互式 USSD 处理程序,我想在用户拨打 USSD 代码时从用户那里获取输入,而不是向他发送响应并关闭会话。 请帮助我如何为用户维护会话并听取他的意见。