/// <summary>
        /// Terminate Im call.
        /// </summary>
        private void TerminateInstantMessagingCall()
        {
            bool exceptionEncountered = true;

            try
            {
                InstantMessagingCall imCall    = null;
                WebImCall            webImCall = m_webConversation.WebImCall;
                if (webImCall != null)
                {
                    imCall = webImCall.ImCall;
                }
                if (imCall != null)
                {
                    imCall.BeginTerminate(this.InstantMessagingCallTerminated, imCall);
                }
                else
                {
                    //Go to next step of terminating av call.
                    this.TerminateAudioVideoCall();
                }

                exceptionEncountered = false;
            }
            finally
            {
                if (exceptionEncountered)
                {
                    OperationFault operationFault = FaultHelper.CreateServerOperationFault(FailureStrings.GenericFailures.UnexpectedException, null /*innerException*/);
                    this.CompleteTerminateConversationOperationWithException(new FaultException <OperationFault>(operationFault));
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Commit Agent Dialog Complete Handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void AgentHuntCompleteHandler(object sender, DialogCompletedEventArgs e)
        {
            Dictionary <string, object> output = e.Output;
            TryCommitAgentAsyncResult   ar;
            bool agentApproval          = output.ContainsKey("QaAgentOfferApproval") ? Convert.ToBoolean(output["QaAgentOfferApproval"]) : false;
            InstantMessagingCall imCall = output.ContainsKey("Call") ? output["Call"] as InstantMessagingCall : null;

            _dictionaryOfTryCommitAsyncResults.TryGetValue((Guid)output["InstanceId"], out ar);
            _dictionaryOfTryCommitAsyncResults.Remove((Guid)output["InstanceId"]);

            if (ar == null)
            {
                Debug.Assert(false, "failed to get TryCommitAgentAsyncResult");
            }

            if (agentApproval)
            {
                ar.SetAsCompleted(imCall, false);
            }

            else
            {
                if (null != imCall)
                {
                    imCall.BeginTerminate(ter => { imCall.EndTerminate(ter); }, null);
                    ar.SetAsCompleted(null, false);
                }
                else
                {
                    ar.SetAsCompleted(new OperationFailureException("AcdAgentHunter: DialogTerminated is getting hit"), false);
                }
            }
        }
Beispiel #3
0
        private void Run()
        {
            // A helper class to take care of platform and endpoint setup and
            // cleanup. This has been abstracted from this sample to focus on
            // Call Control.
            _helper = new UCMASampleHelper();

            // Create a user endpoint using the network credential object
            // defined above. Again, the credentials used must be for a user
            // enabled for Microsoft Lync Server, and capable of logging
            // in from the machine that is running this code.
            _userEndpoint = _helper.CreateEstablishedUserEndpoint(
                "BasicCall Sample User" /* endpointFriendlyName */);

            // Here, we are accepting an Instant Messaging call only.
            // If the incoming call is not an Instant Messaging call (for example,
            // an AudioVideo call, or a custom Call, then it will not get
            // raised to the application. UCMA 3.0 handles this silently by having
            // the call types register for various modalities (as part of the
            // extensibility framework). The appropriate action (here, accepting the
            // call) will be handled in the handler assigned to the method call below.
            _userEndpoint.RegisterForIncomingCall <InstantMessagingCall>(On_InstantMessagingCall_Received);

            // Wait for the call to complete accept, then terminate the conversation.
            Console.WriteLine("Waiting for incoming instant messaging call...");
            _autoResetEvent.WaitOne();

            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shutdown and exit.");

            // Terminate the call, the conversation, and then unregister the
            // endpoint from the receiving an incoming call. Terminating these
            // additional objects individually is made redundant by shutting down
            // the platform right after, but in the multiple call case, this is
            // needed for object hygiene. Terminating a Conversation terminates
            // all it's associated calls, and terminating an endpoint will
            // terminate all conversations on that endpoint.
            _instantMessagingCall.BeginTerminate(EndTerminateCall, _instantMessagingCall);
            _autoResetEvent.WaitOne();
            _instantMessagingCall.Conversation.BeginTerminate(EndTerminateConversation,
                                                              _instantMessagingCall.Conversation);
            _autoResetEvent.WaitOne();
            _userEndpoint.UnregisterForIncomingCall <InstantMessagingCall>(On_InstantMessagingCall_Received);

            //Now, cleanup by shutting down the platform.
            _helper.ShutdownPlatform();
        }
Beispiel #4
0
        public void TerminateCall()
        {
            if (_instantMessagingFlow != null)
            {
                _instantMessagingFlow.StateChanged    -= this.InstantMessagingFlow_StateChanged;
                _instantMessagingFlow.MessageReceived -= this.InstantMessagingFlow_MessageReceived;
                _instantMessagingFlow = null;
            }

            if (_instantMessagingCall != null)
            {
                _instantMessagingCall.BeginTerminate(InstantMessagingCallTerminated, _instantMessagingCall);
                _instantMessagingCall.StateChanged -= this.InstantMessagingCall_StateChanged;
                _instantMessagingCall.InstantMessagingFlowConfigurationRequested -= this.InstantMessagingCall_FlowConfigurationRequested;
                _instantMessagingCall.ConversationChanged -= this.InstantMessagingCall_ConversationChanged;
                _instantMessagingCall = null;
            }
            else
            {
                _waitForIMCallTerminated.Set();
            }

            if (_subConversation != null)
            {
                _transcriptRecorder.OnSubConversationRemoved(_subConversation, this);
                _transcriptRecorder = null;
            }
            if (_subConversation != null)
            {
                _transcriptRecorder.OnSubConversationRemoved(_subConversation, this);
                _subConversation = null;
            }

            _waitForIMCallAccepted.Reset();
            _waitForIMFlowStateChangedToActiveCompleted.Reset();
        }
        private void Run()
        {
            // A helper class to take care of platform and endpoint setup and cleanup.
            _helper = new UCMASampleHelper();

            // Create and establish a user endpoint using the user’s network credentials.
            _userEndpoint = _helper.CreateEstablishedUserEndpoint(
                "FindContact Sample User" /* endpointFriendlyName */);

            // Register a delegate to be called when an incoming InstantMessagingCall arrives.
            _userEndpoint.RegisterForIncomingCall <InstantMessagingCall>(InstantMessagingCall_Received);

            Console.WriteLine("Waiting for an incoming instant messaging call...");
            int ThreadID = Thread.CurrentThread.ManagedThreadId;

            Console.WriteLine("Main thread: ID " + ThreadID);
            // Pause main thread until an incoming call arrives and is accepted.
            _waitUntilIncomingCallIsAccepted.WaitOne();

            InstantMessagingFlow imFlow = _instantMessagingCall.Flow;

            imFlow.BeginSendInstantMessage("Press 1 for Service Department.\n" +
                                           "Press 2 for Sales Department.", CallSendInstantMessageCB, _instantMessagingCall);
            imFlow.MessageReceived += new EventHandler <InstantMessageReceivedEventArgs>(IMFlow_MessageReceived);
            _waitForAvailableTarget.WaitOne();

            if (_remoteContactUri != null)
            {
                imFlow.BeginSendInstantMessage("Contact found: " + _remoteContactUri.ToString(), CallSendInstantMessageCB, _instantMessagingCall);
                // Join the conversation to the IM MCU.
                _conferenceSession = _incomingConversation.ConferenceSession;
                ConferenceJoinOptions confJoinOptions = new ConferenceJoinOptions();
                confJoinOptions.JoinMode = JoinMode.Default;
                _conferenceSession.BeginJoin(confJoinOptions, ConferenceJoinCB, _conferenceSession);

                ThreadID = Thread.CurrentThread.ManagedThreadId;
                Console.WriteLine("Main thread: ID " + ThreadID);
                _waitUntilConferenceInvitationIsDelivered.WaitOne();
            }
            else
            {
                Console.WriteLine("Could not find an available contact.");
                imFlow.BeginSendInstantMessage("Could not find an available contact.\nPlease call again later.", CallSendInstantMessageCB, _instantMessagingCall);
            }
            // Unregister for notification of the MessageReceived event.
            imFlow.MessageReceived -= new EventHandler <InstantMessageReceivedEventArgs>(IMFlow_MessageReceived);
            // Cancel the subscription to the presence session by unsubscribing.
            _userEndpoint.ContactGroupServices.BeginUnsubscribe(ContactGroupUnsubscribeCB, _userEndpoint.ContactGroupServices);
            _remotePresenceView.BeginTerminate(ViewTerminateCB, _remotePresenceView);
            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shut down and exit.");

            // Terminate the call, the conversation, and then unregister the
            // endpoint from receiving an incoming call. Terminating these
            // additional objects individually is made redundant by shutting down
            // the platform right after, but in the multiple call case, this is
            // needed for object hygiene. Terminating a Conversation terminates
            // all its associated calls, and terminating an endpoint
            // terminates all conversations on that endpoint.
            _instantMessagingCall.BeginTerminate(CallTerminateCB, _instantMessagingCall);
            _waitUntilConversationIsTerminated.WaitOne();
            _userEndpoint.UnregisterForIncomingCall <InstantMessagingCall>(InstantMessagingCall_Received);

            // Clean up by shutting down the platform.
            _helper.ShutdownPlatform();
        }
Beispiel #6
0
 private void TerminateIMCall(InstantMessagingCall imCall)
 {
     imCall.BeginTerminate(ar => { Logger.Log(Logger.LogLevel.Info, "IMCall terminated."); imCall.EndTerminate(ar); }, null);
 }