#pragma once #include #include #include #include struct ClientCache { CMutBuffer buffer_; std::array tmp_buf_; }; class CTcpServer { public: CTcpServer(asio::io_context& io_context, const std::shared_ptr& logger); ~CTcpServer(); public: bool Start(unsigned short port); void Stop(); private: void handle_data(CFrameBuffer* buf); private: void Accept(); void HandleClient(std::shared_ptr socket, const std::string& client_key); private: asio::io_context& io_context_; asio::ip::tcp::acceptor acceptor_; std::shared_ptr logger_; std::map> client_map_; std::map client_threads_; std::mutex mutex_; };