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); } FtpCommandHandler handler = m_theCommandHashTable[sCommand] as FtpCommandHandler; if (handler == null) { FtpServerMessageHandler.SendMessage(Id, string.Format("\"{0}\" : Unknown command", sCommand)); SocketHelpers.Send(Socket, "550 Unknown command\r\n"); } else { handler.Process(sValue); } }
private void AddCommand(FtpCommandHandler handler) { m_theCommandHashTable.Add(handler.Command, handler); }