private SIPDialogue Dial(
ForkCall call,
string data,
int ringTimeout,
int answeredCallLimit,
SIPRequest clientRequest,
List <string> customHeaders)
{
SIPDialogue answeredDialogue = null;
ManualResetEvent waitForCallCompleted = new ManualResetEvent(false);
//call.CallProgress += (s, r, h, t, b) => { Log("Progress response of " + s + " received on CallBack Dial" + "."); };
call.CallProgress += CallProgress;
call.CallFailed += (s, r, h) => { waitForCallCompleted.Set(); };
call.CallAnswered += (s, r, toTag, h, t, b, d, transferMode) => { answeredDialogue = d; waitForCallCompleted.Set(); };
try {
Queue <List <SIPCallDescriptor> > callsQueue = m_dialStringParser.ParseDialString(DialPlanContextsEnum.Script, clientRequest, data, customHeaders, null, null, null, null, null, null, null, CustomerServiceLevels.None);
call.Start(callsQueue);
// Wait for an answer.
ringTimeout = (ringTimeout > MAXCALLBACK_RINGTIME_SECONDS || ringTimeout <= 0) ? MAXCALLBACK_RINGTIME_SECONDS : ringTimeout;
logger.Debug("Set callback cancel timeout to " + ringTimeout + " seconds.");
if (!waitForCallCompleted.WaitOne(ringTimeout * 1000, false))
{
call.CancelNotRequiredCallLegs(CallCancelCause.TimedOut);
}
logger.Debug("Callback dial returning has dialogue ? " + (answeredDialogue == null) + ".");
return(answeredDialogue);
}
catch (Exception excp) {
logger.Error("Exception CallbackApp Dial. " + excp);
return(null);
}
}