Exemple #1
0
        public void Process(Byte [] abData)
        {
            string sMessage = System.Text.Encoding.ASCII.GetString(abData);

            sMessage = sMessage.Substring(0, sMessage.IndexOf('\r'));

            FtpServerMessageHandler.SendMessage(Id, sMessage);

            string sCommand;
            string sValue;

            int nSpaceIndex = sMessage.IndexOf(' ');

            if (nSpaceIndex < 0)
            {
                sCommand = sMessage.ToUpper();
                sValue   = "";
            }
            else
            {
                sCommand = sMessage.Substring(0, nSpaceIndex).ToUpper();
                sValue   = sMessage.Substring(sCommand.Length + 1);
            }

            System.Diagnostics.Trace.WriteLine("#### command " + sCommand + "; sValue: " + sValue);

            FtpCommands.FtpCommandHandler handler = m_theCommandHashTable[sCommand] as FtpCommands.FtpCommandHandler;

            if (handler == null)
            {
                FtpServerMessageHandler.SendMessage(Id, string.Format("\"{0}\" : Unknown command", sCommand));
                Assemblies.General.SocketHelpers.Send(Socket, "550 Unknown command\r\n");
            }
            else
            {
                handler.Process(sValue);
            }
        }
Exemple #2
0
 private void AddCommand(FtpCommands.FtpCommandHandler handler)
 {
     m_theCommandHashTable.Add(handler.Command, handler);
 }