/* * @Description: * @Version: 1.0 * @Autor: lishengyin * @Date: 2022-04-11 17:30:58 * @LastEditors: Please set LastEditors * @LastEditTime: 2022-04-11 23:14:30 */ #ifndef __TCPPROXYSESSION_HPP_ #define __TCPPROXYSESSION_HPP_ #include #include #include "Util/logger.h" #include "Util/NoticeCenter.h" #include "UserApp.hpp" #include "Network/TcpServer.h" #include "Network/TcpSession.h" #include #include using namespace std; using namespace toolkit; class TcpProxySession; class ProxySessions { public: std::string NameId; std::shared_ptr session = nullptr; public: ProxySessions(){} ~ProxySessions(){} }; class TcpProxySession: public TcpSession { public: TcpProxySession(const Socket::Ptr &sock) : TcpSession(sock) { DebugL; } ~TcpProxySession() { DebugL; } virtual void onRecv(const Buffer::Ptr &buf) override{ //处理客户端发送过来的数据 TraceL << buf->data() << " from port:" << getIdentifier(); } virtual void onError(const SockException &err) override{ //客户端断开连接或其他原因导致该对象脱离TCPServer管理 WarnL << err.what(); } virtual void onManager() override{ //定时管理该对象,譬如会话超时检查 // DebugL; } private: Ticker _ticker; }; #endif