// // Created by Stepan Usatiuk on 09.12.2024. // #ifndef TCPSERVER_HPP #define TCPSERVER_HPP #include #include #include #include #include #include #include #include "AsyncSslServerTransport.hpp" #include "Helpers.hpp" struct ClientCtx { std::optional client_name; AsyncSslServerTransport transport; std::mutex ctx_mutex; }; class Server { public: Server(uint16_t port, uint32_t ip, std::string cert_path, std::string key_path); void run(); protected: uint16_t _port; uint32_t _ip; std::string _cert_path; std::string _key_path; std::unique_ptr _ssl_ctx; void process_req(int conn_fd); virtual std::vector handle_message(ClientCtx& client, std::vector data) = 0; private: std::atomic _total_req{0}; std::atomic _req_in_progress{0}; std::mutex _req_in_progress_mutex; std::condition_variable _req_in_progress_cond; }; #endif // TCPSERVER_HPP