예제 #1
0
        private async void AriClientOnStasisStartEvent(IAriClient sender, StasisStartEvent e)
        {
            ICall line;

            if (e.Args.Contains("dialed") || e.Args.Contains("SnoopChannel"))
            {
                return;
            }
            _logger.Info("Line Offhook", new
            {
                ChannelId      = e.Channel.Id,
                CallerIdName   = e.Channel.Caller.Number,
                CallerIdNumber = e.Channel.Caller.Name
            });
            line = ArkeCallFactory.CreateArkeCall(e.Channel);
            ConnectedLines.Add(e.Channel.Id, line);
            _logger.Info("Starting Call Script", new
            {
                ChannelId = e.Channel.Id
            });

            // call answered and started
            await line.RunCallScript();

            _logger.Info("Call Script Complete", new { ChannelId = e.Channel.Id });
        }
예제 #2
0
        private async void AriClientOnStasisStartEvent(IAriClient sender, StasisStartEvent e)
        {
            var   callScope = Tracer.Instance.StartActive("NewCall");
            ICall line;

            using (var answerScope = Tracer.Instance.StartActive("AnswerCall"))
            {
                if (e.Args.Contains("dialed") || e.Args.Contains("SnoopChannel"))
                {
                    return;
                }
                callScope.Span.SetTag("ChannelId", e.Channel.Id);
                _logger.Info("Line Offhook", new
                {
                    ChannelId      = e.Channel.Id,
                    CallerIdName   = e.Channel.Caller.Number,
                    CallerIdNumber = e.Channel.Caller.Name
                });
                line = ArkeCallFactory.CreateArkeCall(e.Channel, callScope);
                ConnectedLines.Add(e.Channel.Id, line);
                _logger.Info("Starting Call Script", new
                {
                    ChannelId = e.Channel.Id
                });
            }
            // call answered and started
            await line.RunCallScript();

            _logger.Info("Call Script Complete", new { ChannelId = e.Channel.Id });
            callScope.Close();
        }
예제 #3
0
        private async void AriClientOnStasisStartEvent(IAriClient sender, StasisStartEvent e)
        {
            _logger.Debug($"Line Connecting: {e.Channel.Name}");

            if (e.Args.Contains("dialed") || e.Args.Contains("SnoopChannel"))
            {
                return;
            }
            _logger.Information("Line Offhook", new
            {
                ChannelId      = e.Channel.Id,
                CallerIdName   = e.Channel.Caller.Number,
                CallerIdNumber = e.Channel.Caller.Name
            });
            var line = ArkeCallFactory.CreateArkeCall(e.Channel);

            ConnectedLines.Add(e.Channel.Id, line);
            _logger.Information("Starting Call Script", new
            {
                ChannelId = e.Channel.Id
            });

            // call answered and started
            await line.RunCallScriptAsync(_cancellationToken);

            await Task.Delay(1000, _cancellationToken);

            _logger.Information("Call Script Complete", new { ChannelId = e.Channel.Id });
        }
            private ConnectedLinesEx GetClean(ConnectedLines line, ConnectedLinesEx orig)
            {
                line.RecalculateConnectedCurves();
                var clean = new ConnectedLinesEx(line, orig.MinLength, orig.Length);

                clean.WithinNear = orig.WithinNear;
                return(clean);
            }
예제 #5
0
 private async Task EndAllCalls()
 {
     foreach (var line in ConnectedLines.Where(c => c.Value.CallState.CallCanBeAbandoned))
     {
         line.Value.Hangup();
     }
     foreach (var line in ConnectedLines.Where(c => !c.Value.CallState.CallCanBeAbandoned))
     {
         while (!line.Value.CallState.CallCanBeAbandoned)
         {
             await Task.Delay(1000);
         }
         line.Value.Hangup();
     }
 }
예제 #6
0
        private async void AriClientOnStasisEndEvent(IAriClient sender, StasisEndEvent stasisEndEvent)
        {
            _logger.Info(stasisEndEvent.Channel.Id);
            if (!ConnectedLines.ContainsKey(stasisEndEvent.Channel.Id))
            {
                return;
            }
            ConnectedLines[stasisEndEvent.Channel.Id].Hangup();

            while (!ConnectedLines[stasisEndEvent.Channel.Id].CallState.CallCanBeAbandoned)
            {
                await Task.Delay(1000);
            }
            ConnectedLines.Remove(stasisEndEvent.Channel.Id);
        }
예제 #7
0
 private async Task EndAllCallsAsync()
 {
     foreach (var line in ConnectedLines.Where(c => c.Value.CallState.CallCanBeAbandoned))
     {
         await line.Value.HangupAsync();
     }
     foreach (var line in ConnectedLines.Where(c => !c.Value.CallState.CallCanBeAbandoned))
     {
         while (!line.Value.CallState.CallCanBeAbandoned)
         {
             await Task.Delay(1000, _cancellationToken);
         }
         await line.Value.HangupAsync();
     }
 }
예제 #8
0
        private async void AriClientOnStasisEndEvent(IAriClient sender, StasisEndEvent stasisEndEvent)
        {
            _logger.Information("Channel {channelId} hungup", new { channelId = stasisEndEvent.Channel.Id });
            if (!ConnectedLines.ContainsKey(stasisEndEvent.Channel.Id))
            {
                return;
            }

            try
            {
                await ConnectedLines[stasisEndEvent.Channel.Id].HangupAsync();
            }
            catch (AriException e)
            {
                _logger.Warning($"Exception while hanging up, most likely ok: {e.Message}");
            }

            while (!ConnectedLines[stasisEndEvent.Channel.Id].CallState.CallCanBeAbandoned)
            {
                await Task.Delay(1000, _cancellationToken);
            }
            ConnectedLines.Remove(stasisEndEvent.Channel.Id);
        }
 public void Reset()
 {
     moves.Clear();
     lines.Clear();
     stackCount = 0;
     lineCount = 0;
     if (firstMove != null)
         firstMove.Clear();
     if(connectedLines != null)
         connectedLines.Delete();
     connectedLines = null;
 }
        public void CreateLines()
        {
            float zDepth = 2.0f;
            if (!linesMade)
            {
                //Stack<MortalCoilMove> s1 = new Stack<MortalCoilMove>(moves);
                //s1 = new Stack<MortalCoilMove>(s1);
                List<Vector3> vectors = new List<Vector3>();

                for(int i = stackCount-1; i >= 0; i--)
                {
                    MortalCoilMove move = moves[i];
                    List<Location> locations = move.CloneStack();
                    if (locations.Count > 0)
                    {
                        vectors.Add(new Vector3(locations[locations.Count - 1].x +
                            .5f, locations[locations.Count - 1].y + .5f, zDepth));
                    }
                    Location loc = move.FirstMove;
                    vectors.Add(new Vector3(loc.x + .5f, loc.y + .5f, zDepth));
                    /*
                    while (locations.Count > 0)
                    {
                        Location loc = locations.Pop();
                        if (locations.Count == 0)
                        {
                            vectors.Add(new Vector3(loc.x + .5f, loc.y + .5f, zDepth));
                        }
                    }
                     * */
                }
                vectors.Add(new Vector3(originalLocation.x + .5f, originalLocation.y + .5f, zDepth));
                connectedLines = new ConnectedLines(system, vectors, FACE_System.Color.Green);
                linesMade = true;
            }
        }
            public IEnumerable <ConnectedLinesEx> CleanupNotReportedPairs(
                ConnectedLinesEx errorCandidate)
            {
                if (_notReportedCondition == null)
                {
                    yield return(errorCandidate);

                    yield break;
                }

                AllNotReportedPairConditions notReportedCondition = _notReportedCondition;

                ConnectedLines      subConnected       = null;
                SegmentNeighbors    subNeighbors       = null;
                SegmentPairRelation subRelevantSegment = null;
                int minRelationIndex = SegmentRelationsToCheck.Count;

                foreach (
                    ConnectedSegmentsSubpart allParts in errorCandidate.Line.BaseSegments)
                {
                    IEnumerable <SegmentPartWithNeighbor> neighbors;
                    double limit;
                    Func <SegmentPartWithNeighbor, double, bool>   checkLimit;
                    Func <SegmentPartWithNeighbor, double, double> getLimit;
                    Func <double, bool> checkEndLimit;
                    if (allParts.FullStartFraction > allParts.FullEndFraction)
                    {
                        var sorted =
                            new List <SegmentPartWithNeighbor>(GetNeighbors(allParts));
                        sorted.Sort((x, y) => - x.FullMax.CompareTo(y.FullMax));
                        neighbors = sorted;

                        limit         = allParts.FullMaxFraction;
                        checkLimit    = (x, l) => x.FullMax < l;
                        getLimit      = (x, l) => Math.Min(l, x.FullMin);
                        checkEndLimit = l => l > allParts.FullMinFraction;
                    }
                    else
                    {
                        neighbors     = GetNeighbors(allParts);
                        limit         = allParts.FullMinFraction;
                        checkLimit    = (x, l) => x.FullMin > l;
                        getLimit      = (x, l) => Math.Max(l, x.FullMax);
                        checkEndLimit = l => l < allParts.FullMaxFraction;
                    }

                    ConnectedSegmentsSubpart subSubparts = null;
                    foreach (SegmentPartWithNeighbor segmentPart in neighbors)
                    {
                        if (notReportedCondition.IsFulfilled(
                                allParts.BaseFeature, allParts.TableIndex,
                                segmentPart.NeighborFeature,
                                segmentPart.NeighborTableIndex))
                        {
                            continue;
                        }

                        if (checkLimit(segmentPart, limit) && subConnected != null)
                        {
                            subConnected.RelevantSegment =
                                errorCandidate.Line.RelevantSegment;
                            yield return(GetClean(subConnected, errorCandidate));

                            subConnected = null;
                        }

                        if (subConnected == null)
                        {
                            subConnected =
                                new ConnectedLines(new List <ConnectedSegmentsSubpart>());
                            subRelevantSegment = null;
                            subSubparts        = null;
                        }

                        if (subRelevantSegment == null ||
                            segmentPart.MinRelationIndex <
                            subRelevantSegment.Segment.MinRelationIndex)
                        {
                            subRelevantSegment = new SegmentPairRelation(
                                segmentPart,
                                SegmentRelationsToCheck[segmentPart.MinRelationIndex]);
                        }

                        if (subSubparts == null)
                        {
                            subNeighbors = new SegmentNeighbors(new SegmentPartComparer());

                            var subCurve = new SubClosedCurve(allParts.ConnectedCurve.BaseGeometry,
                                                              allParts.ConnectedCurve.PartIndex,
                                                              segmentPart.FullMin,
                                                              segmentPart.FullMax);

                            subSubparts = new ConnectedSegmentsSubpart(
                                allParts, subNeighbors, subCurve);

                            subConnected.BaseSegments.Add(subSubparts);
                        }

                        SegmentParts parts;
                        var          key = new SegmentPart(
                            Assert.NotNull(segmentPart.SegmentProxy), 0, 1, true);
                        if (!subNeighbors.TryGetValue(key, out parts))
                        {
                            parts = new SegmentParts();
                            subNeighbors.Add(key, parts);
                        }

                        parts.Add(segmentPart);

                        int relationIndex = segmentPart.MinRelationIndex;
                        if (relationIndex < minRelationIndex)
                        {
                            minRelationIndex = relationIndex;
                        }

                        limit = getLimit(segmentPart, limit);
                    }

                    if (checkEndLimit(limit) && subConnected != null)
                    {
                        subConnected.RelevantSegment = errorCandidate.Line.RelevantSegment;
                        yield return(GetClean(subConnected, errorCandidate));

                        subConnected = null;
                    }
                }

                if (subConnected != null)
                {
                    subConnected.RelevantSegment = errorCandidate.Line.RelevantSegment;
                    yield return(GetClean(subConnected, errorCandidate));
                }
            }