LobbyServer.h 967 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * LobbyServer.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../lib/network/NetworkServer.h"
  12. class SQLiteInstance;
  13. class SQLiteStatement;
  14. class LobbyDatabase
  15. {
  16. std::unique_ptr<SQLiteInstance> database;
  17. std::unique_ptr<SQLiteStatement> insertChatMessageStatement;
  18. void initializeDatabase();
  19. void prepareStatements();
  20. void createTableChatMessages();
  21. public:
  22. LobbyDatabase();
  23. void insertChatMessage(const std::string & sender, const std::string & messageText);
  24. };
  25. class LobbyServer : public NetworkServer
  26. {
  27. std::unique_ptr<LobbyDatabase> database;
  28. void onNewConnection(const std::shared_ptr<NetworkConnection> &) override;
  29. void onPacketReceived(const std::shared_ptr<NetworkConnection> &, const std::vector<uint8_t> & message) override;
  30. public:
  31. LobbyServer();
  32. };