Exemplo n.º 1
0
        private void ProcessRequest(requestType request)
        {
            Debug.Assert(request != null);

            ContextChannelRequestReceivedEventArgs eventArgs = null;
            ContextChannelRequest contextChannelRequest      = null;

            MonitoringChannel mChannel = m_monitoringChannel;

            if (!string.IsNullOrEmpty(request.sessionId) &&
                mChannel != null &&
                mChannel.Id.Equals(request.sessionId, StringComparison.OrdinalIgnoreCase))
            {
                mChannel.ProcessRequest(request);
            }
            else
            {
                if (request.startmonitoringsession != null)
                {
                    m_monitoringChannel = new MonitoringChannel(request.startmonitoringsession.sessionId,
                                                                new Uri(request.startmonitoringsession.uri), this);

                    contextChannelRequest = new MonitoringRequest(request, ContextChannelRequestType.StartMonitoring, m_monitoringChannel);
                }
                else if (request.terminatemonitoringsession != null)
                {
                    MonitoringChannel monitoringChannel = m_monitoringChannel;

                    if (monitoringChannel != null &&
                        String.Equals(request.terminatemonitoringsession.sessionId, monitoringChannel.Id, StringComparison.OrdinalIgnoreCase))
                    {
                        contextChannelRequest = new MonitoringRequest(request, ContextChannelRequestType.StopMonitoring, monitoringChannel);
                    }
                }
                else
                {
                    //TODO:Log and ignore
                }

                if (contextChannelRequest != null)
                {
                    eventArgs = new ContextChannelRequestReceivedEventArgs(contextChannelRequest.RequestType, contextChannelRequest);

                    EventHandler <ContextChannelRequestReceivedEventArgs> eventHandler = this.RequestReceived;
                    if (eventHandler != null)
                    {
                        eventHandler.Invoke(this, eventArgs);
                    }
                }
            }
        }
Exemplo n.º 2
0
        internal void ProcessRequest(requestType request)
        {
            Debug.Assert(request != null);

            ContextChannelRequestReceivedEventArgs eventArgs = null;
            ContextChannelRequest contextChannelRequest      = null;

            if (request.bargein != null)
            {
                contextChannelRequest = new ContextChannelRequest(request,
                                                                  ContextChannelRequestType.BargeIn,
                                                                  m_supervisorChannel.InnerChannel);
            }
            else if (request.whisper != null)
            {
                contextChannelRequest = new WhisperRequest(request,
                                                           m_supervisorChannel.InnerChannel);
            }
            //else if (request.terminatemonitoringsession != null)
            //{
            //    contextChannelRequest = new ContextChannelRequest(request,
            //        ContextChannelRequestType.Hold,
            //        m_innerChannel);
            //}
            else
            {
                //TODO:Log and ignore
            }

            eventArgs = new ContextChannelRequestReceivedEventArgs(contextChannelRequest.RequestType, contextChannelRequest);

            EventHandler <ContextChannelRequestReceivedEventArgs> eventHandler = this.RequestReceived;

            if (eventHandler != null)
            {
                eventHandler.Invoke(this, eventArgs);
            }
        }
Exemplo n.º 3
0
        private void ProcessRequest(requestType request)
        {
            Debug.Assert(request != null);

            ContextChannelRequestReceivedEventArgs eventArgs = null;
            ContextChannelRequest contextChannelRequest      = null;

            if (request.hold != null)
            {
                contextChannelRequest = new ContextChannelRequest(request,
                                                                  ContextChannelRequestType.Hold,
                                                                  m_innerChannel);
            }
            else if (request.escalate != null)
            {
                contextChannelRequest = new EscalateRequest(request,
                                                            m_innerChannel);
            }
            else if (request.retrieve != null)
            {
                contextChannelRequest = new ContextChannelRequest(request,
                                                                  ContextChannelRequestType.Retrieve,
                                                                  m_innerChannel);
            }
            else
            {
                //TODO:Log and ignore
            }

            eventArgs = new ContextChannelRequestReceivedEventArgs(contextChannelRequest.RequestType, contextChannelRequest);

            EventHandler <ContextChannelRequestReceivedEventArgs> eventHandler = this.RequestReceived;

            if (eventHandler != null)
            {
                eventHandler.Invoke(this, eventArgs);
            }
        }
Exemplo n.º 4
0
        private void ProcessSupervisorControlChannelRequestReceived(object sender, ContextChannelRequestReceivedEventArgs args)
        {
            _logger.Log("RECEIVED REQUEST: AcdSupervisorSession received the following request: " + args.RequestType);

            switch (args.RequestType)
            {
            case ContextChannelRequestType.StartMonitoring:

                MonitoringRequest startMonitoringRequest = args.Request as MonitoringRequest;

                Agent agentToMonitor = null;

                foreach (Agent agent in _matchMaker.Configuration.Agents)
                {
                    if (SipUriCompare.Equals(agent.SignInAddress, startMonitoringRequest.MonitoringChannel.Uri.ToString()))
                    {
                        agentToMonitor = agent;
                        break;
                    }
                }

                if (null == agentToMonitor)
                {
                    _logger.Log("AcdSupervisorSession could not find the agent to monitor.");
                    args.Request.SendResponse("failure");
                    return;
                }

                if (agentToMonitor.IsAllocated == false)
                {
                    _logger.Log(String.Format("AcdSupervisorSession detected that the agent to monitor was deallocated {0}", agentToMonitor.SignInAddress));
                    args.Request.SendResponse("failure");
                    return;
                }
                if (_state == SupervisorSessionState.AgentMonitoring)
                {
                    _monitoringSession.BeginShutDown(sd =>
                    {
                        _monitoringSession.EndShutDown(sd);
                        _monitoringSession = null;
                        args.Request.SendResponse("Success");

                        this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking);

                        try
                        {
                            this.BeginStartMonitoringSession(startMonitoringRequest.MonitoringChannel,
                                                             agentToMonitor,
                                                             sms =>
                            {
                                try
                                {
                                    this.EndStartMonitoringSession(sms);
                                    args.Request.SendResponse("success");
                                    this.UpdateState(SupervisorSessionState.AgentMonitoring);
                                    return;
                                }
                                catch (RealTimeException rtex)
                                {
                                    _logger.Log("AcdSupervisorSession fails to end start the monitoring session", rtex);
                                    args.Request.SendResponse("failure");
                                    this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking);
                                    return;
                                }
                            },
                                                             null);
                        }
                        catch (InvalidOperationException ivoex)
                        {
                            _logger.Log("AcdSupervisorSession fails to begin start the monitoring session", ivoex);
                            args.Request.SendResponse("failure");
                            this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking);
                            return;
                        }
                    },
                                                     null);
                    return;
                }

                try
                {
                    this.BeginStartMonitoringSession(startMonitoringRequest.MonitoringChannel,
                                                     agentToMonitor,
                                                     sms =>
                    {
                        try
                        {
                            this.EndStartMonitoringSession(sms);
                            args.Request.SendResponse("success");
                            lock (_syncRoot)
                            {
                                if (_state == SupervisorSessionState.JoiningCustomerSession)
                                {
                                    this.UpdateState(SupervisorSessionState.AgentMonitoring);
                                }
                            }
                        }
                        catch (RealTimeException rtex)
                        {
                            _logger.Log("AcdSupervisorSession fails to end start the monitoring session", rtex);
                            args.Request.SendResponse("failure");
                            this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking);
                        }
                    },
                                                     null);
                }
                catch (InvalidOperationException ivoex)
                {
                    _logger.Log("AcdSupervisorSession fails to begin start the monitoring session", ivoex);
                    args.Request.SendResponse("failure");
                    this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking);
                }

                break;

            case ContextChannelRequestType.StopMonitoring:

                if (_state != SupervisorSessionState.AgentMonitoring)
                {
                    _logger.Log("AcdSupervisorSession fails to stop monitoring the session as the supervisorsession is in an invalid state");
                    args.Request.SendResponse("Failure");
                }
                else
                {
                    _monitoringSession.BeginShutDown(sd =>
                    {
                        _monitoringSession.EndShutDown(sd);
                        _monitoringSession = null;
                        args.Request.SendResponse("Success");
                        this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking);
                    },
                                                     null);
                }

                break;

            default:
                _logger.Log("AcdSupervisorSession received a non-supported command");
                args.Request.SendResponse("Failure");
                break;
            }
        }