Ejemplo n.º 1
0
        private TwimlVerbResult RunTwimlVerb(XElement node)
        {
            var             verbfunc        = VerbFunctions.Where(x => x.Method.Name.ToUpper() == node.Name.ToString().ToUpper()).First();
            TwimlVerbResult tvr             = TwimlVerbResult.Continue;
            Thread          ExecutingThread = null;
            var             status          = Task.Factory.StartNew(() =>
            {
                ExecutingThread = Thread.CurrentThread;
                tvr             = verbfunc(node);
            });

            while (!status.IsCompleted)
            {
                Thread.Sleep(100);
                if (GatherNode != null && GatherNode != CurrentNode)
                {
                    if (MyCall.Digits != "")
                    {
                        ExecutingThread.Abort();
                        CurrentNode = GatherNode;
                        return(RunTwimlVerb(GatherNode));
                    }
                }
            }


            return(tvr);
        }
Ejemplo n.º 2
0
        internal void StartCallFlow()
        {
            // start as a new thread
            PopulateVerbFunctions();

            MyCall.CallStatus = CallStatus.ProcessingCall;
            Task.Factory.StartNew(() =>
            {
                thread     = Thread.CurrentThread;
                TwimlPath  = MyCall.CallOptions.Url;
                TwimlLogAs = "Initial Call";
                // get the introductory twiml
                // start procesing
                TwimlVerbResult tvr = TwimlVerbResult.Redirect;
                while (MyCall.CallStatus != CallStatus.Ended && tvr == TwimlVerbResult.Redirect)
                {
                    DoTwimlRequest(TwimlPath, TwimlLogAs);
                    MyCall.Digits = "";
                    GatherNode    = null;
                    CurrentNode   = null;


                    tvr = ProcessReceivedTwiml();
                }

                SystemController.Instance.Office.MarkCallEnded(MyCall, "Twiml Execution ended", true);
            }
                                  , TaskCreationOptions.LongRunning);
        }