public static Task<CallMessageData> EstablishAsync(this Call call,
     string destinationUri, CallEstablishOptions options)
 {
     return Task<CallMessageData>.Factory.FromAsync(
         call.BeginEstablish, call.EndEstablish,
         destinationUri, options, null);
 }
Ejemplo n.º 2
0
 public static Task <CallMessageData> EstablishAsync(this Call call,
                                                     string destinationUri, CallEstablishOptions options)
 {
     return(Task <CallMessageData> .Factory.FromAsync(
                call.BeginEstablish, call.EndEstablish,
                destinationUri, options, null));
 }
 public static Task<CallMessageData> EstablishAsync(this InstantMessagingCall call,
     ToastMessage toastMessage, CallEstablishOptions options)
 {
     return Task<CallMessageData>.Factory.FromAsync(
         call.BeginEstablish, call.EndEstablish,
         toastMessage, options, null);
 }
Ejemplo n.º 4
0
 public static Task<CallMessageData> EstablishAsync(this Call self, CallEstablishOptions options)
 {
     return Task.Factory.FromAsync<CallEstablishOptions, CallMessageData>(
         self.BeginEstablish,
         self.EndEstablish,
         options,
         null);
 }
        /// <summary>
        /// Establishes av call directly to the destination.
        /// </summary>
        private void EstablishAvCallDirectly()
        {
            bool      exceptionEncountered = true;
            Exception exceptionCaught      = null;

            try
            {
                CallEstablishOptions establishOptions = new CallEstablishOptions();
                //Add custom MIME parts based on conversation context.
                if (m_cutomMimePart != null)
                {
                    establishOptions.CustomMimeParts.Add(m_cutomMimePart);
                }
                //Construct the destination uri, if needed.
                m_avCall.BeginEstablish(m_destinationUri, establishOptions, this.AudioVideoCallEstablishCompleted, null /*state*/);
                exceptionEncountered = false;
            }
            catch (ArgumentException ae)
            {
                Helper.Logger.Error("Exception = {0}", EventLogger.ToString(ae));
                exceptionCaught = ae;
            }
            catch (InvalidOperationException ioe)
            {
                Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe));
                exceptionCaught = ioe;
            }
            finally
            {
                if (exceptionEncountered)
                {
                    OperationFault operationFault = null;
                    if (exceptionCaught != null)
                    {
                        operationFault = FaultHelper.CreateClientOperationFault(exceptionCaught.Message, exceptionCaught.InnerException);
                    }
                    else
                    {
                        operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/);
                    }

                    this.CompleteEstablishOperationWithException(new FaultException <OperationFault>(operationFault));
                }
            }
        }
Ejemplo n.º 6
0
        private async Task SendIM(List <string> messages, string toastMessage, string destinationSip)
        {
            Conversation         conversation = new Conversation(_endpoint);
            InstantMessagingCall call         = new InstantMessagingCall(conversation);

            ToastMessage         toast   = new ToastMessage(toastMessage);
            CallEstablishOptions options = new CallEstablishOptions();

            await call.EstablishAsync(destinationSip, toast, options);

            foreach (var msg in messages)
            {
                await call.Flow.SendInstantMessageAsync(msg);
            }
            await conversation.TerminateAsync();

            Console.WriteLine("IM Sent");
        }
Ejemplo n.º 7
0
        private async Task SendIM(List<string> messages, string toastMessage, string destinationSip)
        {

            Conversation conversation = new Conversation(_endpoint);
            InstantMessagingCall call = new InstantMessagingCall(conversation);

            ToastMessage toast = new ToastMessage(toastMessage);
            CallEstablishOptions options = new CallEstablishOptions();

            await call.EstablishAsync(destinationSip, toast, options);
            foreach (var msg in messages)
            {
                await call.Flow.SendInstantMessageAsync(msg);
            }
            await conversation.TerminateAsync();
            Console.WriteLine("IM Sent");
        }
 internal bool MakeCall(string calledPartyUri, string callerPartyUri)
 {
     this.DebugTrace("Inside BaseUMconnectivityTester MakeCall, calledParty ={0}, callerParty = {1}", new object[]
     {
         calledPartyUri,
         callerPartyUri
     });
     lock (this)
     {
         try
         {
             Conversation conversation = new Conversation(this.endPoint);
             if (!string.IsNullOrEmpty(callerPartyUri))
             {
                 conversation.Impersonate(callerPartyUri, null, null);
             }
             this.audioCall = new AudioVideoCall(conversation);
             this.audioCall.StateChanged += this.OnStateChanged;
             this.audioCall.InfoReceived += this.OnMessageReceived;
             this.audioCall.AudioVideoFlowConfigurationRequested += this.OnAudioVideoFlowConfigurationRequested;
             this.audioCall.Forwarded += this.OnRedirect;
             CallEstablishOptions callEstablishOptions = new CallEstablishOptions();
             callEstablishOptions.ConnectionContext = this.GetConnectionContext();
             this.callEndedEvent        = new ManualResetEvent(false);
             this.mediaEstablishedEvent = new ManualResetEvent(false);
             callEstablishOptions.Headers.Add(new SignalingHeader("msexum-connectivitytest", this.SignalingHeaderValue));
             this.audioCall.EndEstablish(this.audioCall.BeginEstablish(calledPartyUri, callEstablishOptions, null, null));
             this.WaitForMediaEstablishment(calledPartyUri);
             this.AttachToneController();
             this.HandleConnectionEstablished();
             this.isCallEstablished = true;
         }
         catch (TUC_MakeCallError tuc_MakeCallError)
         {
             this.error = tuc_MakeCallError;
             this.ErrorTrace("Inside BaseUMconnectivityTester MakeCall, error ={0}", new object[]
             {
                 tuc_MakeCallError
             });
             return(false);
         }
         catch (RealTimeException ex)
         {
             this.error = new TUC_MakeCallError(calledPartyUri, ex.Message, ex);
             this.ErrorTrace("Inside BaseUMconnectivityTester MakeCall, error ={0}", new object[]
             {
                 ex
             });
             return(false);
         }
         catch (InvalidOperationException ex2)
         {
             this.error = new TUC_MakeCallError(calledPartyUri, ex2.Message, ex2);
             this.ErrorTrace("Inside BaseUMconnectivityTester MakeCall, error ={0}", new object[]
             {
                 ex2
             });
             return(false);
         }
         catch (ArgumentException ex3)
         {
             this.error = new TUC_MakeCallError(calledPartyUri, ex3.Message, ex3);
             this.ErrorTrace("Inside BaseUMconnectivityTester MakeCall, error ={0}", new object[]
             {
                 ex3
             });
             return(false);
         }
     }
     return(this.isCallEstablished);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Call remote user and start TranscriptRecorderSession on Conversation
 /// </summary>
 /// <param name="remoteUserUri"></param>
 /// <param name="options"></param>
 public async Task StartConversationTranscriptRecorderSession(string remoteUserUri, CallEstablishOptions options = null)
 {
     throw new NotImplementedException("StartConversationTranscriptRecorderSession is not yet implemented");
 }
Ejemplo n.º 10
0
        public override async Task<AcdActionResult> Execute(LocalEndpoint localEndpoint, AudioVideoCall call, CancellationToken cancellationToken)
        {
            if (Endpoint == null)
                return AcdActionResult.Continue;

            // extract information from incoming caller
            var callParticipant = call.RemoteEndpoint.Participant;
            var callAddress = new RealTimeAddress(callParticipant.Uri, localEndpoint.DefaultDomain, localEndpoint.PhoneContext);
            var callSipUri = new SipUriParser(callAddress.Uri);
            callSipUri.RemoveParameter(new SipUriParameter("user", "phone"));
            var callUri = callSipUri.ToString();
            var callPhoneUri = callParticipant.OtherPhoneUri;
            var callName = callParticipant.DisplayName;

            // impersonate incoming caller to agent
            var remoteConversation = new Conversation(localEndpoint);
            remoteConversation.Impersonate(callUri, callPhoneUri, callName);

            // establish call to endpoint
            var remoteCall = new AudioVideoCall(remoteConversation);
            var remoteOpts = new CallEstablishOptions();
            remoteOpts.Transferor = localEndpoint.OwnerUri;
            remoteOpts.Headers.Add(new SignalingHeader("Ms-Target-Class", "secondary"));

            // initiate call with duration
            var destCallT = remoteCall.EstablishAsync(Endpoint.Uri, remoteOpts, cancellationToken);

            try
            {
                // wait for agent call to complete
                await destCallT;
            }
            catch (OperationCanceledException)
            {
                // ignore
            }
            catch (RealTimeException)
            {
                // ignore
            }

            // ensure two accepted transfers cannot both complete
            using (var lck = await call.GetContext<AsyncLock>().LockAsync())
                if (call.State == CallState.Established)
                    if (remoteCall.State == CallState.Established)
                    {
                        var participant = remoteConversation.RemoteParticipants.FirstOrDefault();
                        if (participant != null)
                        {
                            var endpoint = participant.GetEndpoints().FirstOrDefault(i => i.EndpointType == EndpointType.User);
                            if (endpoint != null)
                            {
                                var ctx = new ConversationContextChannel(remoteConversation, endpoint);

                                // establish conversation context with application
                                await ctx.EstablishAsync(
                                    new Guid("FA44026B-CC48-42DA-AAA8-B849BCB43A21"), 
                                    new ConversationContextChannelEstablishOptions());

                                // send context data
                                await ctx.SendDataAsync(
                                    new ContentType("text/plain"), 
                                    Encoding.UTF8.GetBytes("Id=123"));
                            }
                        }

                        return await TransferAsync(call, remoteCall);
                    }

            // terminate outbound call if still available
            if (remoteCall.State != CallState.Terminating &&
                remoteCall.State != CallState.Terminated)
                await remoteCall.TerminateAsync();

            // we could not complete the transfer attempt
            return AcdActionResult.Continue;
        }
Ejemplo n.º 11
0
 public static Task <CallMessageData> EstablishAsync(this InstantMessagingCall call,
                                                     ToastMessage toastMessage, CallEstablishOptions options)
 {
     return(Task <CallMessageData> .Factory.FromAsync(
                call.BeginEstablish, call.EndEstablish,
                toastMessage, options, null));
 }
 /// <summary>
 /// Call remote user and start TranscriptRecorderSession on Conversation
 /// </summary>
 /// <param name="remoteUserUri"></param>
 /// <param name="options"></param>
 public async Task StartConversationTranscriptRecorderSession(string remoteUserUri, CallEstablishOptions options = null)
 {
     throw new NotImplementedException("StartConversationTranscriptRecorderSession is not yet implemented");
 }
Ejemplo n.º 13
0
 public static Task<CallMessageData> EstablishAsync(this Call self, string destinationUri, CallEstablishOptions options, CancellationToken cancellationToken)
 {
     return EstablishAsync(self, destinationUri, options)
         .WithCancellation(cancellationToken, () =>
             self.TerminateAsync());
 }