public void Execute(
DialPlanContext dialPlanContext,
ISIPServerUserAgent uas,
SIPCallDirection callDirection,
DialogueBridgeCreatedDelegate createBridgeDelegate,
ISIPCallManager callManager)
{
if (dialPlanContext == null)
{
throw new ArgumentNullException("The DialPlanContext parameter cannot be null when attempting to execute a dialplan.");
}
if (uas.IsUASAnswered)
{
// This can occur if the call is cancelled by the caller between when the INVITE was received and when the dialplan execution was ready.
logger.Warn("Dialplan execution for " + dialPlanContext.SIPDialPlan.DialPlanName + " for " + uas.CallDirection + " call to " + uas.CallDestination + " did not proceed as call already answered.");
dialPlanContext.DialPlanExecutionFinished();
}
else
{
if (dialPlanContext.ContextType == DialPlanContextsEnum.Line)
{
ThreadPool.QueueUserWorkItem(delegate { ExecuteDialPlanLine((DialPlanLineContext)dialPlanContext, uas, callDirection, createBridgeDelegate, callManager); });
}
else
{
ExecuteDialPlanScript((DialPlanScriptContext)dialPlanContext, uas, callDirection, createBridgeDelegate, callManager);
}
}
}