Esempio n. 1
0
        /// <summary>
        /// Handle incoming audio call from the customer.
        /// </summary>
        /// <param name="audioCall">Audio call.</param>
        public void HandleIncomingAudioCall(AudioVideoCall audioCall)
        {
            lock (syncRoot)
            {
                if (this.conversation == null)
                {
                    this.conversation = audioCall.Conversation;
                    this.RegisterConversationEventHandlers(this.conversation);
                }

                this.audioIvr = new AudioIVR(audioCall, this.application.XmlParser, this.logger);

                try
                {
                    audioCall.BeginAccept((asyncResult) =>
                    {
                        try
                        {
                            audioCall.EndAccept(asyncResult);
                        }
                        catch (RealTimeException rte)
                        {
                            Console.WriteLine("Error accepting incoming AV call {0}", rte);
                            this.logger.Log("Error accepting incoming AV call {0}", rte);
                        }
                    },
                                          null);
                }
                catch (InvalidOperationException ioe)
                {
                    Console.WriteLine("Error accepting incoming AV call {0}", ioe);
                    this.logger.Log("Error accepting incoming AV call {0}", ioe);
                }
            }
        }
        private void AcceptCall(AudioVideoCall call)
        {
            _avCall = call;

            try
            {
                // Accept the incoming call.
                _avCall.BeginAccept(ar =>
                {
                    try
                    {
                        _avCall.EndAccept(ar);

                        _logger.Log("Accepted incoming call.");
                    }
                    catch (RealTimeException rtex)
                    {
                        _logger.Log("Failed accepting incoming A/V call.", rtex);
                    }
                },
                null);
            }
            catch (InvalidOperationException ioex)
            {
                _logger.Log("Failed accepting incoming A/V call.", ioex);
            }
        }
Esempio n. 3
0
        public void AcceptAVCall(AudioVideoCall call)
        {
            //Console.WriteLine("Accepting incoming AV call");
            
            try
            {
                call.BeginAccept(
                ar =>
                {
                    try
                    {
                        call.Flow.StateChanged += new EventHandler<MediaFlowStateChangedEventArgs>(Flow_StateChanged);

                        call.EndAccept(ar);
                        SpeakMessage(call.Flow, string.Format("Hello, {0}. Thanks for calling. "
                            + "Your SIP URI is {1}",
                            call.RemoteEndpoint.Participant.DisplayName,
                            call.RemoteEndpoint.Participant.Uri));
                    }
                    catch (RealTimeException ex)
                    {
                        Console.WriteLine("Failed tp accept call.", ex);
                    }
                },
                null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine("Failed tp accept call.", ex);
            }            
        }
Esempio n. 4
0
        void On_AudioVideoCall_Received(object sender, CallReceivedEventArgs <AudioVideoCall> e)
        {
            // Type checking was done by the platform; no risk of this being any
            // type other than the type expected.
            AudioVideoCall _audioVideoCall = e.Call;

            // Call: StateChanged: Only hooked up for logging, to show the call
            // state transitions. Only bound on the incoming side, to avoid
            // printing the events twice.
            _audioVideoCall.StateChanged += this.Call_StateChanged;

            // Remote Participant URI represents the far end (caller) in this
            // conversation. Toast is the message set by the caller as the 'greet'
            // message for this call. In Microsoft Lync, the toast will
            // show up in the lower-right of the screen.
            Console.WriteLine("");
            Console.WriteLine(" Audio Video Call Received! From: " + e.RemoteParticipant.Uri);
            Console.WriteLine(" Toast is: " + e.ToastMessage.Message);
            Console.WriteLine(" Conversation ID is: " + e.Call.Conversation.Id);
            Console.WriteLine("");

            try
            {
                // Now, accept the call. Threading note: AcceptCallCompleted will
                // be raised on the same thread. Blocking this thread in this
                // portion of the code will cause endless waiting.
                _audioVideoCall.BeginAccept(AcceptCallCompleted, _audioVideoCall);
            }
            catch (InvalidOperationException exception)
            {
                // InvalidOperationException indicates that the call was
                // disconnected before it could be accepted.
                Console.WriteLine(exception.ToString());
            }
        }
        private void OnIncomingAudioVideoCallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e)
        {
            _avCall = e.Call;

            _avCall.StateChanged += new EventHandler<CallStateChangedEventArgs>(OnCallStateChanged);

            try
            {
                // Accept the incoming call.
                _avCall.BeginAccept(ar =>
                {
                    try
                    {
                        _avCall.EndAccept(ar);

                        _logger.Log("Accepted incoming call.");

                        PerformAttendedTransfer();
                    }
                    catch (RealTimeException rtex)
                    {
                        _logger.Log("Failed accepting incoming A/V call.", rtex);
                    }
                },
                null);
            }
            catch (InvalidOperationException ioex)
            {
                _logger.Log("Failed accepting incoming A/V call.", ioex);
            }
        }
        private void OnIncomingAudioVideoCallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e)
        {
            _avCall = e.Call;

            try
            {
                // Accept the incoming call.
                _avCall.BeginAccept(ar =>
                {
                    try
                    {
                        _avCall.EndAccept(ar);

                        _logger.Log("Accepted incoming call.");
                    }
                    catch (RealTimeException rtex)
                    {
                        _logger.Log("Failed accepting incoming A/V call.", rtex);
                    }
                },
                null);
            }
            catch (InvalidOperationException ioex)
            {
                _logger.Log("Failed accepting incoming A/V call.", ioex);
            }
        }
Esempio n. 7
0
        //call received event handler
        public void AudioVideoCall_Received(CallReceivedEventArgs <AudioVideoCall> e)
        {
            if (_state == TranscriptRecorderState.Terminated)
            {
                NonBlockingConsole.WriteLine("Error: AVTranscriptRecorder is shutdown.");
                // TODO: Error message
                return;
            }

            if (_audioVideoCall != null)
            {
                NonBlockingConsole.WriteLine("Warn: AVCall already exists for this Conversation. Shutting down previous call...");
                // TODO: Info message
                TerminateCall();
            }

            _state = TranscriptRecorderState.Initialized;
            _waitForAudioVideoCallTerminated.Reset();

            //Type checking was done by the platform; no risk of this being any
            // type other than the type expected.
            _audioVideoCall = e.Call;

            // Call: StateChanged: Only hooked up for logging, to show the call
            // state transitions.
            _audioVideoCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(AudioVideoCall_StateChanged);

            // Subscribe for the flow configuration requested event; the flow will be used to send the media.
            // Ultimately, as a part of the callback, the media will be sent/recieved.
            _audioVideoCall.AudioVideoFlowConfigurationRequested += new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(AudioVideoCall_FlowConfigurationRequested);

            _audioVideoCall.ConversationChanged += new EventHandler <ConversationChangedEventArgs>(AudioVideoCall_ConversationChanged);

            // Remote Participant URI represents the far end (caller) in this
            // conversation. Toast is the message set by the caller as the 'greet'
            // message for this call. In Microsoft Lync, the toast will
            // show up in the lower-right of the screen.
            // TODO: change this to preserve confidentiality in the video demo
            //NonBlockingConsole.WriteLine("Call Received! From: " + e.RemoteParticipant.Uri + " Toast is: " + e.ToastMessage.Message);
            NonBlockingConsole.WriteLine("Call Received! From: " + e.RemoteParticipant.Uri);
            //NonBlockingConsole.WriteLine("Call Received!");

            Message m = new Message("AudioVideoCall Received. Inbound call state: " + _audioVideoCall.State.ToString(),
                                    e.RemoteParticipant.DisplayName, e.RemoteParticipant.UserAtHost, e.RemoteParticipant.Uri,
                                    MessageType.Audio, _transcriptRecorder.Conversation.Id, MessageDirection.Incoming);

            _transcriptRecorder.OnMessageReceived(m);

            // Accept the call. Before transferring the call, it must be in the Established state.
            // Note that the docs are wrong in the state machine for the AVCall. BeginEstablish
            // should be called on outgoing calls, not incoming calls.
            _audioVideoCall.BeginAccept(AudioVideoCallAccepted, _audioVideoCall);

            // Wait for a few seconds to give time for the call to get to the Established state.
            //_waitForAudioVideoCallAccepted.WaitOne(2000);
            NonBlockingConsole.WriteLine("Inbound call state is {0}\n", _audioVideoCall.State.ToString());
        }
        // The delegate to be called when the inbound call arrives (the call from a customer).
        private void inboundAVCall_CallReceived(object sender, CallReceivedEventArgs <AudioVideoCall> e)
        {
            _waitForCallReceived.Set();
            _audioVideoCall = e.Call;

            _audioVideoCall.AudioVideoFlowConfigurationRequested += this.audioVideoCall_FlowConfigurationRequested;
            _audioVideoCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(audioVideoCall_StateChanged);

            // Create a new conversation instance.
            _conversation = new Conversation(_userEndpoint);
            // Accept the call.
            _audioVideoCall.BeginAccept(CallAcceptCB, _audioVideoCall);
            _audioVideoFlow = _audioVideoCall.Flow;
        }
Esempio n. 9
0
        // Delegate that is called when an incoming AudioVideoCall arrives.
        void AudioVideoCall_Received(object sender, CallReceivedEventArgs <AudioVideoCall> e)
        {
            _audioVideoCall = e.Call;
            _audioVideoCall.AudioVideoFlowConfigurationRequested += this.AudioVideoCall_FlowConfigurationRequested;

            // For logging purposes, register for notification of the StateChanged event on the call.
            _audioVideoCall.StateChanged +=
                new EventHandler <CallStateChangedEventArgs>(AudioVideoCall_StateChanged);

            // Remote Participant URI represents the far end (caller) in this conversation.
            Console.WriteLine("Call received from: " + e.RemoteParticipant.Uri);

            // Now, accept the call. CallAcceptCB will run on the same thread.
            _audioVideoCall.BeginAccept(CallAcceptCB, _audioVideoCall);
        }
Esempio n. 10
0
        /// <summary>
        /// EventHandler raised when an incoming call arrives to the endpoint, above.
        /// </summary>
        /// <param name="sender">Object that sent the event</param>
        /// <param name="e">CallReceivedEventArgs object</param>
        private void AudioVideoCallReceived(object sender, CallReceivedEventArgs <AudioVideoCall> e)
        {
            //Assign the current call to the global keeper.
            currentCall = e.Call;

            currentCall.AudioVideoFlowConfigurationRequested += new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(Call_AudioVideoFlowConfigurationRequested);

            //Bind handlers to the current call's state changed event to drive UI.
            //State change is used to inform the application of the current state of the call.
            //In particular, this should be used by the application to determine what operations are valid in a given state.
            currentCall.StateChanged
                += new EventHandler <CallStateChangedEventArgs>(HandleCallStateChanged);

            // accept the incoming call and waits for State and configuration requests.
            currentCall.EndAccept(currentCall.BeginAccept(null, null));
        }
Esempio n. 11
0
        void On_AudioVideoCall_Received(object sender, CallReceivedEventArgs <AudioVideoCall> e)
        {
            // Type checking was done by the platform; no risk of this being any
            // type other than the type expected.
            _audioVideoCall = e.Call;

            // Call: StateChanged: Only hooked up for logging, to show the call
            // state transitions.
            _audioVideoCall.StateChanged += this.AudioVideoCall_StateChanged;

            // Remote Participant URI represents the far end (caller) in this
            // conversation. Toast is the message set by the caller as the 'greet'
            // message for this call. In Microsoft Lync, the toast will
            // show up in the lower-right of the screen.
            Console.WriteLine("Call Received! From: " + e.RemoteParticipant.Uri);

            // Now, accept the call.
            // EndAcceptCall will be raised on the same thread.
            _audioVideoCall.BeginAccept(EndAcceptCall, _audioVideoCall);
        }
        //call received event handler
        public void AudioVideoCall_Received(CallReceivedEventArgs<AudioVideoCall> e)
        {
            if (_state == TranscriptRecorderState.Terminated)
            {
                NonBlockingConsole.WriteLine("Error: AVTranscriptRecorder is shutdown.");
                // TODO: Error message
                return;
            }

            if (_audioVideoCall != null)
            {
                NonBlockingConsole.WriteLine("Warn: AVCall already exists for this Conversation. Shutting down previous call...");
                // TODO: Info message
                TerminateCall();
            }

            _state = TranscriptRecorderState.Initialized;
            _waitForAudioVideoCallTerminated.Reset();

            //Type checking was done by the platform; no risk of this being any 
            // type other than the type expected.
            _audioVideoCall = e.Call;

            // Call: StateChanged: Only hooked up for logging, to show the call 
            // state transitions.
            _audioVideoCall.StateChanged += new EventHandler<CallStateChangedEventArgs>(AudioVideoCall_StateChanged);

            // Subscribe for the flow configuration requested event; the flow will be used to send the media.
            // Ultimately, as a part of the callback, the media will be sent/recieved.
            _audioVideoCall.AudioVideoFlowConfigurationRequested += new EventHandler<AudioVideoFlowConfigurationRequestedEventArgs>(AudioVideoCall_FlowConfigurationRequested);

            _audioVideoCall.ConversationChanged += new EventHandler<ConversationChangedEventArgs>(AudioVideoCall_ConversationChanged);

            // Remote Participant URI represents the far end (caller) in this 
            // conversation. Toast is the message set by the caller as the 'greet'
            // message for this call. In Microsoft Lync, the toast will 
            // show up in the lower-right of the screen.
            // TODO: change this to preserve confidentiality in the video demo
            //NonBlockingConsole.WriteLine("Call Received! From: " + e.RemoteParticipant.Uri + " Toast is: " + e.ToastMessage.Message);
            NonBlockingConsole.WriteLine("Call Received! From: " + e.RemoteParticipant.Uri);
            //NonBlockingConsole.WriteLine("Call Received!");

            Message m = new Message("AudioVideoCall Received. Inbound call state: " + _audioVideoCall.State.ToString(),
                e.RemoteParticipant.DisplayName, e.RemoteParticipant.UserAtHost, e.RemoteParticipant.Uri,
                MessageType.Audio, _transcriptRecorder.Conversation.Id, MessageDirection.Incoming);
            _transcriptRecorder.OnMessageReceived(m);

            // Accept the call. Before transferring the call, it must be in the Established state.
            // Note that the docs are wrong in the state machine for the AVCall. BeginEstablish 
            // should be called on outgoing calls, not incoming calls.
            _audioVideoCall.BeginAccept(AudioVideoCallAccepted, _audioVideoCall);

            // Wait for a few seconds to give time for the call to get to the Established state.
            //_waitForAudioVideoCallAccepted.WaitOne(2000);
            NonBlockingConsole.WriteLine("Inbound call state is {0}\n", _audioVideoCall.State.ToString());
        }
Esempio n. 13
0
        private void OnIncomingAudioVideoCallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e)
        {
            _avCall = e.Call;

            try
            {
                // Accept the incoming call.
                _avCall.BeginAccept(ar =>
                {
                    try
                    {
                        _avCall.EndAccept(ar);

                        _logger.Log("Accepted incoming call.");

                        switch (_transferType)
                        {
                            case TransferTypeSelection.Attended:
                                PerformAttendedTransfer();
                                break;
                            case TransferTypeSelection.Unattended:
                                PerformUnattendedTransfer();
                                break;
                            case TransferTypeSelection.Supervised:
                                PerformSupervisedTransfer();
                                break;
                        }
                    }
                    catch (RealTimeException rtex)
                    {
                        _logger.Log("Failed accepting incoming A/V call.", rtex);
                    }
                },
                null);
            }
            catch (InvalidOperationException ioex)
            {
                _logger.Log("Failed accepting incoming A/V call.", ioex);
            }
        }