Ejemplo n.º 1
0
 public static ReadingState GetInstance()
 {
     if (s_State == null)
     {
         s_State = new ReadingState();
     }
     return(s_State);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 执行命令,如果命令是与登录相关则不执行
        /// </summary>
        /// <returns>如果返回true,则说明命令执行成功</returns>
        public override bool IssueCommand(RFC1939.POPCommand command, POPClient context)
        {
            if (!IsLegalCommand(command))
            {
                return(false);
            }

            if (command is RFC1939.QuitCommand)
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    context.CurrentState = DisconnectedState.GetInstane();
                    return(true);
                }
                context.CurrentState = DisconnectedState.GetInstane();
                context.LoggCommand(command);
            }
            else if (command is RFC1939.RetriveCommand || command is RFC1939.TopCommand)
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    context.CurrentState = ReadingState.GetInstance();
                    return(true);
                }
                context.LoggCommand(command);
            }
            else if (command is RFC1939.NoopCommand)
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    return(true);
                }
                else
                {
                    context.LoggCommand(command);
                    context.Disconnect();
                    context.CurrentState = DisconnectedState.GetInstane();
                }
            }
            else
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    return(true);
                }
                context.LoggCommand(command);
            }
            return(false);
        }