Beispiel #1
0
 public override void Context()
 {
     _callCollection           = mock <ICallCollection>();
     _pendingSpecification     = mock <IPendingSpecification>();
     _callActions              = mock <ICallActions>();
     _callSpecificationFactory = mock <ICallSpecificationFactory>();
 }
Beispiel #2
0
        /// <summary>
        /// Incoming call handler.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="CollectionEventArgs{TEntity}"/> instance containing the event data.</param>
        private void CallsOnIncoming(ICallCollection sender, CollectionEventArgs <ICall> args)
        {
            var call = args.AddedResources.First();

            var callee   = call.Resource.Targets.First();
            var callType = callee?.Identity?.GetApplicationInstance() == null ? IncidentCallType.BotIncoming : IncidentCallType.BotEndpointIncoming;

            var incidentCallContext = new IncidentCallContext(callType, Guid.Empty.ToString());

            AddCallToHandlers(call, incidentCallContext);

            var mediaToPrefetch = new List <MediaInfo>();

            foreach (var m in MediaMap)
            {
                mediaToPrefetch.Add(m.Value.MediaInfo);
            }

            var answerTask = call.AnswerAsync(
                mediaToPrefetch,
                new[] { Modality.Audio });

            Task.Run(async() =>
            {
                try
                {
                    await answerTask.ConfigureAwait(false);
                    graphLogger.Info("Started answering incoming call");
                }
                catch (Exception ex)
                {
                    graphLogger.Error(ex, "Exception happened when answering the call.");
                }
            });
        }
Beispiel #3
0
        /// <summary>
        /// Incoming call handler
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="CollectionEventArgs{ICall}"/> instance containing the event data.</param>
        private void CallsOnIncoming(ICallCollection sender, CollectionEventArgs <ICall> args)
        {
            Task answerTask;

            var call = args.AddedResources.First();

            var callee   = call.Resource.Targets.First();
            var callType = callee?.Identity?.GetApplicationInstance() == null ? CallType.BotIncoming : CallType.BotEndpointIncoming;


            var callHandler = new IncomingCallHandler(this, call);

            this.callHandlers[call.Resource.Id] = callHandler;
            var mediaConfig = new List <MediaInfo>();

            answerTask = call.AnswerAsync(mediaConfig, new[] { Modality.Audio });

            Task.Run(async() =>
            {
                try
                {
                    await answerTask.ConfigureAwait(false);
                    this.graphLogger.Info("Started answering incoming call");
                }
                catch (Exception ex)
                {
                    this.graphLogger.Error(ex, $"Exception happened when answering the call.");
                }
            });
        }
Beispiel #4
0
        /// <summary>
        /// Updated call handler.
        /// </summary>
        /// <param name="sender">The <see cref="ICallCollection"/> sender.</param>
        /// <param name="args">The <see cref="CollectionEventArgs{ICall}"/> instance containing the event data.</param>
        private void CallsOnUpdated(ICallCollection sender, CollectionEventArgs <ICall> args)
        {
            var    request    = new { Type = "call_update", Content = args };
            string jsonString = JsonSerializer.Serialize(request);

            using (var client = new HttpClient())
            {
                var response = client.PostAsync("https://ngage.eastus2.cloudapp.azure.com:2145/teamsbot", new StringContent(jsonString, Encoding.UTF8, "application/json")).Result;

                if (response.IsSuccessStatusCode)
                {
                    var responseContent = response.Content;

                    // by calling .Result you are synchronously reading the result
                    string responseString = responseContent.ReadAsStringAsync().Result;

                    Console.WriteLine(responseString);
                }
            }

            foreach (var call in args.RemovedResources)
            {
                if (this.CallHandlers.TryRemove(call.Id, out CallHandler handler))
                {
                    handler.Dispose();
                }
            }
        }
Beispiel #5
0
 public override void Context()
 {
     _callCollection          = mock <ICallCollection>();
     _call                    = mock <ICall>();
     _sequenceNumberGenerator = mock <SequenceNumberGenerator>();
     _sequenceNumberGenerator.stub(x => x.Next()).Return(42);
 }
 public CheckReceivedCallsHandler(ICallCollection receivedCalls, ICallSpecificationFactory callSpecificationFactory, IReceivedCallsExceptionThrower exceptionThrower, MatchArgs matchArgs, Quantity requiredQuantity)
 {
     _receivedCalls            = receivedCalls;
     _callSpecificationFactory = callSpecificationFactory;
     _exceptionThrower         = exceptionThrower;
     _matchArgs        = matchArgs;
     _requiredQuantity = requiredQuantity;
 }
Beispiel #7
0
 public GetCallSpec(ICallCollection callCollection, IPendingSpecification pendingSpecification,
     ICallSpecificationFactory callSpecificationFactory, ICallActions callActions)
 {
     _callCollection = callCollection;
     _pendingSpecification = pendingSpecification;
     _callSpecificationFactory = callSpecificationFactory;
     _callActions = callActions;
 }
Beispiel #8
0
 public GetCallSpec(ICallCollection callCollection, IPendingSpecification pendingSpecification,
                    ICallSpecificationFactory callSpecificationFactory, ICallActions callActions)
 {
     _callCollection           = callCollection;
     _pendingSpecification     = pendingSpecification;
     _callSpecificationFactory = callSpecificationFactory;
     _callActions = callActions;
 }
 /// <summary>
 /// Incoming call handler.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The <see cref="CollectionEventArgs{TEntity}"/> instance containing the event data.</param>
 private void CallsOnIncoming(ICallCollection sender, CollectionEventArgs <ICall> args)
 {
     args.AddedResources.ForEach(call =>
     {
         // Answer call and start processing.
         var mediaSession = this.CreateLocalMediaSession(call?.CorrelationId ?? Guid.Empty);
         call?.AnswerAsync(mediaSession).ForgetAndLogExceptionAsync($"Answering call {call.Id} with correlation {call.CorrelationId}.", this.logger);
     });
 }
 /// <summary>
 /// Updated call handler.
 /// </summary>
 /// <param name="sender">The <see cref="ICallCollection"/> sender.</param>
 /// <param name="args">The <see cref="CollectionEventArgs{ICall}"/> instance containing the event data.</param>
 private void CallsOnUpdated(ICallCollection sender, CollectionEventArgs <ICall> args)
 {
     foreach (var call in args.RemovedResources)
     {
         if (this.CallHandlers.TryRemove(call.Id, out CallHandler handler))
         {
             handler.Dispose();
         }
     }
 }
Beispiel #11
0
        /// <summary>
        /// Incoming call handler.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="CollectionEventArgs{TEntity}"/> instance containing the event data.</param>
        private void CallsOnIncoming(ICallCollection sender, CollectionEventArgs <ICall> args)
        {
            args.AddedResources.ForEach(call =>
            {
                IMediaSession mediaSession = Guid.TryParse(call.Id, out Guid callId)
                    ? this.CreateLocalMediaSession(callId)
                    : this.CreateLocalMediaSession();

                // Answer call and start video playback
                call?.AnswerAsync(mediaSession).ForgetAndLogExceptionAsync(
                    call.GraphLogger,
                    $"Answering call {call.Id} with scenario {call.ScenarioId}.");
            });
        }
Beispiel #12
0
        /// <summary>
        /// Updated call handler.
        /// </summary>
        /// <param name="sender">The <see cref="ICallCollection"/> sender.</param>
        /// <param name="args">The <see cref="CollectionEventArgs{ICall}"/> instance containing the event data.</param>
        private void CallsOnUpdated(ICallCollection sender, CollectionEventArgs <ICall> args)
        {
            foreach (var call in args.AddedResources)
            {
                var callHandler = new CallHandler(call, call.GraphLogger);
                this.CallHandlers[call.Id] = callHandler;
            }

            foreach (var call in args.RemovedResources)
            {
                if (this.CallHandlers.TryRemove(call.Id, out CallHandler handler))
                {
                    handler.Dispose();
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// Incoming call handler.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="CollectionEventArgs{TEntity}"/> instance containing the event data.</param>
        private void CallsOnIncoming(ICallCollection sender, CollectionEventArgs <ICall> args)
        {
            args.AddedResources.ForEach(call =>
            {
                // Get the compliance recording parameters.

                // The context associated with the incoming call.
                IncomingContext incomingContext =
                    call.Resource.IncomingContext;

                // The RP participant.
                string observedParticipantId =
                    incomingContext.ObservedParticipantId;

                // If the observed participant is a delegate.
                IdentitySet onBehalfOfIdentity =
                    incomingContext.OnBehalfOf;

                // If a transfer occured, the transferor.
                IdentitySet transferorIdentity =
                    incomingContext.Transferor;

                string countryCode        = null;
                EndpointType?endpointType = null;

                // Note: this should always be true for CR calls.
                if (incomingContext.ObservedParticipantId == incomingContext.SourceParticipantId)
                {
                    // The dynamic location of the RP.
                    countryCode = call.Resource.Source.CountryCode;

                    // The type of endpoint being used.
                    endpointType = call.Resource.Source.EndpointType;
                }

                IMediaSession mediaSession = Guid.TryParse(call.Id, out Guid callId)
                    ? this.CreateLocalMediaSession(callId)
                    : this.CreateLocalMediaSession();

                // Answer call
                call?.AnswerAsync(mediaSession).ForgetAndLogExceptionAsync(
                    call.GraphLogger,
                    $"Answering call {call.Id} with scenario {call.ScenarioId}.");
            });
        }
Beispiel #14
0
 public GetCallSpec(ICallCollection receivedCalls, ICallSpecificationFactory callSpecificationFactory, ICallActions callActions)
 {
     _receivedCalls            = receivedCalls;
     _callSpecificationFactory = callSpecificationFactory;
     _callActions = callActions;
 }
Beispiel #15
0
 public RecordCallHandler(ICallCollection callCollection, SequenceNumberGenerator generator)
 {
     _callCollection = callCollection;
     _generator      = generator;
 }
 public RecordCallHandler(ICallCollection callCollection, SequenceNumberGenerator generator)
 {
     _callCollection = callCollection;
     _generator = generator;
 }