TelnetServer.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef RVC_SPSHELLTELNET_SERVER_H_
  2. #define RVC_SPSHELLTELNET_SERVER_H_
  3. #pragma once
  4. #include "IOCPSocketServer.h"
  5. #include "AutoLock.h"
  6. #include <map>
  7. #include <list>
  8. #include <vector>
  9. using namespace std;
  10. class CTelnetServer : public CIOCPSocketServer
  11. {
  12. public:
  13. CTelnetServer(void);
  14. virtual ~CTelnetServer(void);
  15. #if defined(_MSC_VER)
  16. vector<string> SplitString(const char *pLine, char notDelimiterChars[] = NULL);
  17. void SetIgnoreArrowKeys(bool bIgnore){m_bIgnoreArrowKey = bIgnore;}
  18. protected:
  19. virtual void OnEvent(const char *pFormat, ...);
  20. virtual void OnError(const char *pFormat, ...);
  21. virtual string GetPromptString() { return "Telnet Service> ";}
  22. virtual string GetHelloString() { return "Welcome to telnet service, for any help, press [?] or [help]\r\n";}
  23. virtual bool ParseCmdLine(int nConnectionID, const char *pCmdLine, string &strReplyMsg)
  24. {
  25. strReplyMsg = "not supported command: {";
  26. strReplyMsg += pCmdLine;
  27. strReplyMsg += "}\r\n";
  28. return false;
  29. }
  30. string GetLocalTimeString(bool bShort = true);
  31. private:
  32. void OnAccepte(int nConnectionID, const char *pRemoteAddr, int nPort);
  33. void OnSend(int nConnectionID, int nSendLen);
  34. void OnReceive(int nConnectionID, char *pData, int nRecvLen);
  35. void OnClose(int nConnectionID);
  36. string GetErrorReplyString(string errMsg);
  37. bool IsCharIncluded(char ch, char chars[]);
  38. void OnConsoleOutput(bool bError, const char *pFormat, va_list arg);
  39. CLockObject m_LockObject;
  40. struct SessionContext;
  41. map<int, SessionContext*> m_SessionContext;
  42. bool m_bIgnoreArrowKey;
  43. #endif /*RVC_OS_WIN*/
  44. };
  45. #endif /*RVC_SPSHELLTELNET_SERVER_H_*/