예제 #1
0
        private void EndJoinConference(IAsyncResult ar)
        {
            ConferenceSession confSession = ar.AsyncState as ConferenceSession;

            try
            {
                confSession.EndJoin(ar);
            }
            catch (ConferenceFailureException confFailEx)
            {
                // ConferenceFailureException may be thrown on failures due to
                // MCUs being absent or unsupported, or due to malformed parameters.
                // TODO (Left to the reader): Add error handling code
                Console.WriteLine(confFailEx.ToString());
            }
            catch (RealTimeException rTEx)
            {
                // TODO (Left to the reader): Add error handling code
                Console.WriteLine(rTEx.ToString());
            }
            finally
            {
                //Again, for sync. reasons.
                _waitForConferenceJoin.Set();
            }
        }
예제 #2
0
        private void EndCalleeJoinConference(IAsyncResult ar)
        {
            ConferenceSession confSession = ar.AsyncState as ConferenceSession;

            try
            {
                confSession.EndJoin(ar);
            }
            catch (OperationFailureException opFailEx)
            {
                // OperationFailureException: Indicates failure to connect the
                // call to the remote party.
                // TODO (Left to the reader): Add error handling code here.
                Console.WriteLine(opFailEx.ToString());
            }
            catch (RealTimeException realTimeEx)
            {
                // RealTimeException may be thrown on media or link-layer failures,
                // or call rejection (FailureResponseException)
                // TODO (Left to the reader): Add error handling code here.
                Console.WriteLine(realTimeEx.ToString());
            }

            // As mentioned before, if this is the first party to escalate, the
            // remote party will receive an escalation request, via the event on
            // the far end conversation, EscalateToConferenceRequested. Also, the
            // existing calls will be shifted to the MCUs.
            confSession.Conversation.BeginEscalateToConference(EndCalleeEscalateConference,
                                                               confSession.Conversation);
        }
        /// <summary>
        /// Occurs when bot joined the conference.
        /// </summary>
        /// <param name="argument">The argument.</param>
        /// <remarks></remarks>
        public void EndJoinEscalatedConference(IAsyncResult argument)
        {
            ConferenceSession conferenceSession = argument.AsyncState as ConferenceSession;
            Exception         exception         = null;

            try
            {
                NonBlockingConsole.WriteLine("Joined the conference");
                conferenceSession.EndJoin(argument);
                NonBlockingConsole.WriteLine(string.Format(
                                                 "Conference Url: conf:{0}%3Fconversation-id={1}",
                                                 conferenceSession.ConferenceUri,
                                                 conferenceSession.Conversation.Id));

                _conference = conferenceSession;

                RegisterConferenceEvents();

                // Raise event on TranscriptRecorderSession
                _transcriptRecorder.RaiseTranscriptRecorderSessionChanged(_conference);

                // In case Bot was dragged into existing conversation or someone was dragged into existing conversation with Bot;
                // it will create ad-hoc conference and here is the place where we need to escalate current call into conference.
                conferenceSession.Conversation.BeginEscalateToConference(EndEscalateConversation, conferenceSession.Conversation);
            }
            catch (ConferenceFailureException conferenceFailureException)
            {
                // ConferenceFailureException may be thrown on failures due to MCUs being absent or unsupported, or due to malformed parameters.
                // It is left to the application to perform real error handling here.
                NonBlockingConsole.WriteLine(conferenceFailureException.ToString());
                exception = conferenceFailureException;
            }
            catch (RealTimeException realTimeException)
            {
                // It is left to the application to perform real error handling here.
                NonBlockingConsole.WriteLine(realTimeException.ToString());
                exception = realTimeException;
            }
            finally
            {
                if (exception != null)
                {
                    string originator = string.Format("Error when joining the escalated conference.");
                    NonBlockingConsole.WriteLine(originator);
                }

                _waitForEscalatedConferenceJoined.Set();
            }
        }
        // Callback method referred to in the call to BeginJoin on the ConferenceSession instance.
        private void ConferenceJoinCB(IAsyncResult ar)
        {
            ConferenceSession conferenceSession = ar.AsyncState as ConferenceSession;

            try
            {
                conferenceSession.EndJoin(ar);
                Console.WriteLine("Conversation state: " + _incomingConversation.State.ToString());
                Console.WriteLine("Conference session state: " + _conferenceSession.State.ToString());
                _incomingConversation.BeginEscalateToConference(ConferenceEscalateCB, _incomingConversation);
                int ThreadID = Thread.CurrentThread.ManagedThreadId;
                Console.WriteLine("Conf join callback thread: ID " + ThreadID);
            }

            // A production application should have catch blocks for a number
            // of other exceptions, including ConferenceFailureException, FailureRequestException,
            // and OperationFailureException.
            catch (RealTimeException exception)
            {
                Console.WriteLine(exception.ToString());
            }
        }