1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #ifndef RVC_SPSHELLTELNET_SERVER_H_
- #define RVC_SPSHELLTELNET_SERVER_H_
- #pragma once
- #include "IOCPSocketServer.h"
- #include "AutoLock.h"
- #include <map>
- #include <list>
- #include <vector>
- using namespace std;
- class CTelnetServer : public CIOCPSocketServer
- {
- public:
- CTelnetServer(void);
- virtual ~CTelnetServer(void);
- #if defined(_MSC_VER)
- vector<string> SplitString(const char *pLine, char notDelimiterChars[] = NULL);
- void SetIgnoreArrowKeys(bool bIgnore){m_bIgnoreArrowKey = bIgnore;}
-
- protected:
- virtual void OnEvent(const char *pFormat, ...);
- virtual void OnError(const char *pFormat, ...);
-
- virtual string GetPromptString() { return "Telnet Service> ";}
- virtual string GetHelloString() { return "Welcome to telnet service, for any help, press [?] or [help]\r\n";}
- virtual bool ParseCmdLine(int nConnectionID, const char *pCmdLine, string &strReplyMsg)
- {
- strReplyMsg = "not supported command: {";
- strReplyMsg += pCmdLine;
- strReplyMsg += "}\r\n";
- return false;
- }
- string GetLocalTimeString(bool bShort = true);
-
- private:
- void OnAccepte(int nConnectionID, const char *pRemoteAddr, int nPort);
- void OnSend(int nConnectionID, int nSendLen);
- void OnReceive(int nConnectionID, char *pData, int nRecvLen);
- void OnClose(int nConnectionID);
-
- string GetErrorReplyString(string errMsg);
- bool IsCharIncluded(char ch, char chars[]);
- void OnConsoleOutput(bool bError, const char *pFormat, va_list arg);
-
- CLockObject m_LockObject;
-
- struct SessionContext;
- map<int, SessionContext*> m_SessionContext;
- bool m_bIgnoreArrowKey;
- #endif /*RVC_OS_WIN*/
- };
- #endif /*RVC_SPSHELLTELNET_SERVER_H_*/
|