1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #ifndef APPLICATION_H
- #define APPLICATION_H
- #include "request_handler.hpp"
- class Application {
- binom::DynamicStorage db; ///< Server database
- TcpServer server; ///< TCP Server
- EVP_PKEY* server_key; ///< Server key pair
- struct AppIniter {
- uint16_t server_port = 33333;
- const char* server_name = nullptr;
- const char* db_path = "data.binomdb";
- bool init_db = false;
- };
- AppIniter processArgs(int argc, char* argv[]);
- // Server handlers
- void dataHandler(DataBuffer& data, TcpServer::Client& client);
- void connectHandler(TcpServer::Client& client);
- void disconnectHandler(TcpServer::Client& client);
- Application(AppIniter app_initer);
- public:
- /**
- * @brief Application constructor
- * @param argc - argument count
- * @param argv - argument vector
- */
- Application(int argc, char* argv[]);
- };
- class PerfomanceTest {
- clock_t start_time;
- const char* msg;
- public:
- PerfomanceTest(const char* msg) : start_time(clock()), msg(msg) {}
- ~PerfomanceTest() {std::clog << msg << double( clock() - start_time ) / (double)CLOCKS_PER_SEC << " seconds." << std::endl;}
- };
- #endif // APPLICATION_H
|