application.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef APPLICATION_H
  2. #define APPLICATION_H
  3. #include "request_handler.hpp"
  4. class Application {
  5. binom::DynamicStorage db; ///< Server database
  6. TcpServer server; ///< TCP Server
  7. EVP_PKEY* server_key; ///< Server key pair
  8. struct AppIniter {
  9. uint16_t server_port = 33333;
  10. const char* server_name = nullptr;
  11. const char* db_path = "data.binomdb";
  12. bool init_db = false;
  13. };
  14. AppIniter processArgs(int argc, char* argv[]);
  15. // Server handlers
  16. void dataHandler(DataBuffer& data, TcpServer::Client& client);
  17. void connectHandler(TcpServer::Client& client);
  18. void disconnectHandler(TcpServer::Client& client);
  19. Application(AppIniter app_initer);
  20. public:
  21. /**
  22. * @brief Application constructor
  23. * @param argc - argument count
  24. * @param argv - argument vector
  25. */
  26. Application(int argc, char* argv[]);
  27. };
  28. class PerfomanceTest {
  29. clock_t start_time;
  30. const char* msg;
  31. public:
  32. PerfomanceTest(const char* msg) : start_time(clock()), msg(msg) {}
  33. ~PerfomanceTest() {std::clog << msg << double( clock() - start_time ) / (double)CLOCKS_PER_SEC << " seconds." << std::endl;}
  34. };
  35. #endif // APPLICATION_H