Esempio n. 1
0
        /// <summary>
        /// Handles an incoming Application Sharing call. The incoming Application  Sharing call can be one of two things:
        /// this can be a brand new customer session or a modality escalation. Else decline.
        /// </summary>
        private void HandleApplicationSharingCallReceived(object sender, CallReceivedEventArgs <ApplicationSharingCall> args)
        {
            //Declines if it is a brand new Conversation as we only expect, modality escalation in
            // an existing customer session for Application Sharing.
            if (args.IsNewConversation == true)
            {
                try
                {
                    args.Call.Decline(new CallDeclineOptions(ResponseCode.TemporarilyUnavailable));
                }
                catch (InvalidOperationException ivoex)
                {
                    _logger.Log("AcdPortal cannot decline an imcoming Application Sharing Call properly", ivoex);
                }
                catch (RealTimeException ex)
                {
                    _logger.Log("AcdPortal cannot decline an imcoming Application Sharing Call properly", ex);
                }
            }
            else if (args.IsNewConversation == false)
            {
                //this an Application Sharing escalation, hand off the call to the AcdCustomerSession for futher processing
                if (null != args.Call.Conversation.ApplicationContext)
                {
                    AcdCustomerSession session = args.Call.Conversation.ApplicationContext as AcdCustomerSession;
                    args.RingBackDisabled = true;

                    ThreadPool.QueueUserWorkItem((waitState) =>
                    {
                        session.HandleNewModality(args.Call);
                    });
                }
                else
                {
                    // There was an issue retrieving the AcdCustomerSession, we are declining the call.
                    try
                    {
                        args.Call.Decline(new CallDeclineOptions(ResponseCode.TemporarilyUnavailable));
                    }
                    catch (InvalidOperationException ivoex)
                    {
                        _logger.Log("AcdPortal cannot decline an imcoming Application Sharing Call properly", ivoex);
                    }
                    catch (RealTimeException ex)
                    {
                        _logger.Log("AcdPortal cannot decline incoming Application Sharing call properly", ex);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handles an incoming Instant Messaging call. The incoming Instant Messaging call can be one of two things:
        /// this can be a brand new customer session or a modality escalation. Else decline.
        /// </summary>
        private void HandleInstantMessagingCallReceived(object sender, CallReceivedEventArgs <InstantMessagingCall> args)
        {
            //Determines whether it is a new Call
            if (args.IsNewConversation == true)  //New acd customer session
            {
                //Decline the call if the portal is draining its calls, else hand it off to a newly created Acd Customer session.
                if (_portalState < PortalState.Draining)  //Only take new calls is we're not in the process of shutting down.
                {
                    AcdCustomerSession session = new AcdCustomerSession(_logger, _matchMaker, this);

                    //add the session to the list.
                    lock (_syncRoot)
                    {
                        _sessions.Add(session);
                        _numberOfSessionsEstablished++;
                    }
                    session.CustomerSessionStateChanged += CustomerSessionStateChanged;

                    if (args.CustomMimeParts.Count > 0)
                    {
                        productType       productInfo;
                        List <AgentSkill> listOfRequestedSkills = new List <AgentSkill>(this.ProcessMimeParts(args.CustomMimeParts, out productInfo));

                        ThreadPool.QueueUserWorkItem((waitState) =>
                        {
                            session.HandleInitialCall(args.Call, listOfRequestedSkills, productInfo);
                        });
                    }
                    else
                    {
                        ThreadPool.QueueUserWorkItem((waitState) =>
                        {
                            session.HandleInitialCall(args.Call, null, null);
                        });
                    }
                }
                else //If the call comes in while we're shutting down, terminate it
                {
                    //UNDONE: Nice to have: - Play a message to the user that the portal is shutting down.
                    try
                    {
                        args.Call.Decline(new CallDeclineOptions(ResponseCode.TemporarilyUnavailable));
                    }
                    catch (RealTimeException ex)
                    {
                        _logger.Log("AcdPortal cannot decline incoming IM call properly while draining/terminating the portal", ex);
                    }
                }
            }
            else
            {
                //this an audio escalation, hand off the call to the AcdCustomerSession for futher processing
                if (null != args.Call.Conversation.ApplicationContext)
                {
                    AcdCustomerSession session = args.Call.Conversation.ApplicationContext as AcdCustomerSession;

                    ThreadPool.QueueUserWorkItem((waitState) =>
                    {
                        session.HandleNewModality(args.Call);
                    });
                }
                else
                {
                    // There was an issue retrieving the AcdCustomerSession, we are declining the call.

                    try
                    {
                        args.Call.Decline();
                    }
                    catch (InvalidOperationException ex)
                    {
                        _logger.Log("AcdPortal cannot decline incoming IM call properly; the call must already be terminated", ex);
                    }
                    catch (RealTimeException ex)
                    {
                        _logger.Log("AcdPortal cannot decline incoming IM call properly", ex);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Handles incoming AudioVideoCall. The incoming call can be one of three things: a brand new conversation,
        /// a self transfer of an existing customer-facing call, an audio escalation. In Draining mode, only the incoming
        /// calls for existing Conversations will be processed. Initial Conversation calls coming in will be declined by the
        /// endpoint.
        /// </summary>
        private void HandleAudioVideoCallReceived(object sender, CallReceivedEventArgs <AudioVideoCall> args)
        {
            //Determines whether it is a new Call
            if (args.IsNewConversation && args.CallToBeReplaced == null)   //New Acd customer session
            {
                AcdCustomerSession session = new AcdCustomerSession(_logger, _matchMaker, this);

                //add the session to the list.
                lock (_syncRoot)
                {
                    _sessions.Add(session);
                    _numberOfSessionsEstablished++;
                }

                //registering for an event to monitor the customer session state in order to determine when the draining is complete.
                session.CustomerSessionStateChanged += CustomerSessionStateChanged;

                if (args.CustomMimeParts.Count > 0)
                {
                    productType productInformation;

                    List <AgentSkill> listOfRequestedSkills = new List <AgentSkill>(this.ProcessMimeParts(args.CustomMimeParts, out productInformation));

                    ThreadPool.QueueUserWorkItem((waitState) =>
                    {
                        session.HandleInitialCall(args.Call, listOfRequestedSkills, productInformation);
                    });
                }
                else
                {
                    ThreadPool.QueueUserWorkItem((waitState) =>
                    {
                        session.HandleInitialCall(args.Call, null, null);
                    });
                }
            }
            //it is not a new call but a modality addition
            else if (args.IsNewConversation == false && args.CallToBeReplaced == null)
            {
                if (null != args.Call.Conversation.ApplicationContext)
                {
                    //this an audio escalation, hand-off the call to the AcdCustomerSession for futher processing
                    AcdCustomerSession session = args.Call.Conversation.ApplicationContext as AcdCustomerSession;
                    args.RingBackDisabled = true;
                    session.HandleNewModality(args.Call);
                }
                else
                {
                    // There was an issue retrieving the AcdCustomerSession, we are declining the call.
                    try
                    {
                        args.Call.Decline(new CallDeclineOptions(ResponseCode.TemporarilyUnavailable));
                    }
                    catch (RealTimeException ex)
                    {
                        _logger.Log("AcdPortal cannot decline incoming audio call properly", ex);
                    }
                }
            }
            else if (args.CallToBeReplaced != null)
            {
                try
                {
                    args.Call.Decline();
                }
                catch (RealTimeException ex)
                {
                    _logger.Log("AcdPortal failed declining an incoming call replacing an exisiting one", ex);
                }
            }
            else
            {
                //unexpected. Decline the incoming call
                try
                {
                    args.Call.Decline();
                }
                catch (RealTimeException ex)
                {
                    _logger.Log("Acd customer session failed to decline an unexpected incoming Audio call", ex);
                }
            }
        }