Esempio n. 1
0
        public override bool ProcessCommand(byte[] buffer, int offset, int count) //处理分完包的数据,子类从这个方法继承
        {
            DownloadSocketCommand command = StrToCommand(m_incomingDataParser.Command);

            m_outgoingDataAssembler.Clear();
            m_outgoingDataAssembler.AddResponse();
            m_outgoingDataAssembler.AddCommand(m_incomingDataParser.Command);
            if (!CheckLogined(command)) //检测登录
            {
                m_outgoingDataAssembler.AddFailure(ProtocolCode.UserHasLogined, "");
                return(DoSendResult());
            }
            switch (command)
            {
            case DownloadSocketCommand.Login: return(DoLogin());

            case DownloadSocketCommand.Active: return(DoActive());

            case DownloadSocketCommand.Dir: return(DoDir());

            case DownloadSocketCommand.FileList: return(DoFileList());

            case DownloadSocketCommand.Download: return(DoDownload());

            default:
                Program.Logger.Error("Unknow command: " + m_incomingDataParser.Command);
                return(false);
            }
        }
 public bool CheckLogined(DownloadSocketCommand command)
 {
     if ((command == DownloadSocketCommand.Login) | (command == DownloadSocketCommand.Active))
     {
         return(true);
     }
     else
     {
         return(m_logined);
     }
 }
        public override bool ProcessCommand(byte[] buffer, int offset, int count)
        {
            DownloadSocketCommand command = StrToCommand(m_incomingDataParser.Command);

            m_outgoingDataAssembler.Clear();
            m_outgoingDataAssembler.AddResponse();
            m_outgoingDataAssembler.AddCommand(m_incomingDataParser.Command);
            if (!CheckLogined(command))
            {
                m_outgoingDataAssembler.AddFailure(ProtocolCode.UserHasLogined, "");
                return(DoSendResult());
            }
            if (command == DownloadSocketCommand.Active)
            {
                return(DoActive());
            }
            else if (command == DownloadSocketCommand.Login)
            {
                return(DoLogin());
            }
            else if (command == DownloadSocketCommand.Dir)
            {
                return(DoDir());
            }
            else if (command == DownloadSocketCommand.FileList)
            {
                return(DoFileList());
            }
            else if (command == DownloadSocketCommand.Download)
            {
                return(DoDownload());
            }
            else
            {
                Program.Logger.ErrorFormat("Unknown Command : ", m_incomingDataParser.Command);
                return(false);
            }
        }
Esempio n. 4
0
        public override bool ProcessCommand(byte[] buffer, int offset, int count) //处理分完包的数据,子类从这个方法继承
        {
            DownloadSocketCommand command = StrToCommand(m_incomingDataParser.Command);

            m_outgoingDataAssembler.Clear();
            m_outgoingDataAssembler.AddResponse();
            m_outgoingDataAssembler.AddCommand(m_incomingDataParser.Command);
            if (!CheckLogined(command)) //检测登录
            {
                m_outgoingDataAssembler.AddFailure(ProtocolCode.UserHasLogined, "");
                return(DoSendResult());
            }
            if (command == DownloadSocketCommand.Login)
            {
                return(DoLogin());
            }
            else if (command == DownloadSocketCommand.Active)
            {
                return(DoActive());
            }
            else if (command == DownloadSocketCommand.Dir)
            {
                return(DoDir());
            }
            else if (command == DownloadSocketCommand.FileList)
            {
                return(DoFileList());
            }
            else if (command == DownloadSocketCommand.Download)
            {
                return(DoDownload());
            }
            else
            {
                Debug.WriteLog.Log(eLogLevel.ell_Error, "Unknow command: " + m_incomingDataParser.Command);
                return(false);
            }
        }
 public bool CheckLogined(DownloadSocketCommand command)
 {
     if ((command == DownloadSocketCommand.Login) | (command == DownloadSocketCommand.Active))
         return true;
     else
         return m_logined;
 }