2023-11-11 16:43:58 +02:00
|
|
|
/*
|
|
|
|
* LobbyServer.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../lib/network/NetworkServer.h"
|
|
|
|
|
|
|
|
class SQLiteInstance;
|
2023-11-12 15:32:54 +02:00
|
|
|
class SQLiteStatement;
|
2023-11-11 16:43:58 +02:00
|
|
|
|
2023-11-12 15:32:54 +02:00
|
|
|
class LobbyDatabase
|
2023-11-11 16:43:58 +02:00
|
|
|
{
|
|
|
|
std::unique_ptr<SQLiteInstance> database;
|
2023-11-12 15:32:54 +02:00
|
|
|
std::unique_ptr<SQLiteStatement> insertChatMessageStatement;
|
|
|
|
|
|
|
|
void initializeDatabase();
|
|
|
|
void prepareStatements();
|
|
|
|
void createTableChatMessages();
|
|
|
|
public:
|
|
|
|
LobbyDatabase();
|
|
|
|
|
|
|
|
void insertChatMessage(const std::string & sender, const std::string & messageText);
|
|
|
|
};
|
|
|
|
|
|
|
|
class LobbyServer : public NetworkServer
|
|
|
|
{
|
|
|
|
std::unique_ptr<LobbyDatabase> database;
|
2023-11-11 16:43:58 +02:00
|
|
|
|
2023-11-12 13:27:22 +02:00
|
|
|
void onNewConnection(const std::shared_ptr<NetworkConnection> &) override;
|
|
|
|
void onPacketReceived(const std::shared_ptr<NetworkConnection> &, const std::vector<uint8_t> & message) override;
|
2023-11-11 16:43:58 +02:00
|
|
|
public:
|
|
|
|
LobbyServer();
|
|
|
|
};
|