예제 #1
0
        //就绪
        public void CancelNotReadyForMedia()
        {
            try
            {
                RequestCancelNotReadyForMedia request = RequestCancelNotReadyForMedia.Create("chat", null);

                LogRequest(request.ToString());
                protocolManagementService[ISERVER_IDENTIFIER].Send(request);
            }
            catch (Exception e)
            {
                LogException(e);
            }
        }
        public OpenMediaReadyAction(IProtocol protocol) :
            base(protocol)
        {
            base.Request = RequestCancelNotReadyForMedia.Create("chat", null);

            OrPredicate <IMessage> filter = new OrPredicate <IMessage>(
                new MessageIdFilter(EventAck.MessageId),
                new MessageIdFilter(EventAgentAvailable.MessageId));

            filter.AddPredicate(new AgentStatusFilter("chat", 1));

            base.SuccessFilter = filter;
            base.FailureFilter = new MessageIdFilter(EventError.MessageId);
        }
        /// <summary>
        /// Agents the ready.
        /// </summary>
        /// <param name="proxyClientId">The proxy client identifier.</param>
        /// <param name="mediaType">Type of the media.</param>
        /// <returns></returns>
        public OutputValues AgentReady(int proxyClientId, string mediaType)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                RequestCancelNotReadyForMedia requestAgentReady = RequestCancelNotReadyForMedia.Create();
                requestAgentReady.ProxyClientId = proxyClientId;
                requestAgentReady.MediaTypeName = mediaType;
                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestAgentReady);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck eventAgentReady = (EventAck)message;
                            logger.Info("---------------AgentReady---------------");
                            logger.Info("ProxyClientId    :" + proxyClientId);
                            logger.Info("MediaTypeName    :" + mediaType);
                            logger.Info("Name    :" + eventAgentReady.Name.ToString());
                            logger.Info("----------------------------------------");
                            logger.Trace(eventAgentReady.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Agent Ready Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError            = (EventError)message;
                            string     LoginErrorCode        = Convert.ToString(eventError.ErrorCode);
                            string     LoginErrorDescription = Convert.ToString(eventError.ErrorDescription);
                            logger.Trace(eventError.ToString());
                            output.ErrorCode   = eventError.ErrorCode;
                            output.MessageCode = "2002";
                            output.Message     = "AgentReady() : " + LoginErrorDescription;
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Agent Ready UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("AgentReady() : Interaction Server Protocol is Null..");
                }
            }
            catch (Exception commonException)
            {
                logger.Error("Error occurred while Agent Ready request " + commonException.ToString());
                output.MessageCode = "2001";
                output.Message     = commonException.Message;
            }
            return(output);
        }