SIPSorcery.AppServer.DialPlan.ForkCall.Start C# (CSharp) Method

Start() public method

Starts a call based on a single multi forward call leg.
public Start ( List callDescriptors ) : void
callDescriptors List
return void
        public void Start(List<SIPCallDescriptor> callDescriptors)
        {
            if (callDescriptors != null && callDescriptors.Count > 0)
            {
                for (int index = 0; index < callDescriptors.Count; index++)
                {
                    int availableThreads = 0;
                    int ioCompletionThreadsAvailable = 0;
                    ThreadPool.GetAvailableThreads(out availableThreads, out ioCompletionThreadsAvailable);

                    if (availableThreads <= 0)
                    {
                        logger.Warn("The ThreadPool had no threads available in the pool to start a ForkCall leg, task will be queued.");
                    }

                    SIPCallDescriptor callDescriptor = callDescriptors[index];
                    FireProxyLogEvent(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "ForkCall commencing call leg to " + callDescriptor.Uri + ".", m_username));
                    ThreadPool.QueueUserWorkItem(delegate { StartNewCallAsync(callDescriptor); });
                }
            }
            else
            {
                CallLegCompleted();
            }
        }

Same methods

ForkCall::Start ( Queue callsQueue ) : void

Usage Example

示例#1
0
        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);
            }
        }
All Usage Examples Of SIPSorcery.AppServer.DialPlan.ForkCall::Start