Snake/SnakeServer/Server/mainserver.h

47 lines
1.1 KiB
C
Raw Normal View History

2019-03-10 16:56:42 +03:00
#ifndef SERVER_H
#define SERVER_H
#include <serverprotocol.h>
#include "server_global.h"
#include <QHostAddress>
2019-05-18 19:05:36 +03:00
#include <clientprotocol.h>
2019-03-10 16:56:42 +03:00
namespace ServerProtocol {
class Server;
}
namespace ClientProtocol {
class Server;
2019-04-29 14:39:48 +03:00
class BaseNetworkObject;
2019-03-10 16:56:42 +03:00
}
2019-05-18 19:05:36 +03:00
class SqlDBCache;
2019-03-10 16:56:42 +03:00
class SERVERSHARED_EXPORT MainServer: public QObject
{
Q_OBJECT
private:
ServerProtocol::Server *_terminalPort = nullptr;
ClientProtocol::Server *_serverDaemon= nullptr;
2019-05-18 19:05:36 +03:00
SqlDBCache* _db = nullptr;
2019-03-10 16:56:42 +03:00
bool payItem(int player, int idItem);
bool sellItem(int player, int idItem);
bool restartSrver(const QString& ip, unsigned short port);
private slots:
2019-05-18 19:05:36 +03:00
void handleRequest(ClientProtocol::Command cmd, const QByteArray &data,
2019-04-29 14:39:48 +03:00
const quint32& addres);
2019-03-10 16:56:42 +03:00
void handleTerminalRequest(QVariantMap obj);
public:
MainServer(QObject *ptr = nullptr);
bool run(const QString& ip = "", unsigned short port = 0, const QString &db = "",
const QString &terminalServer = "", bool terminalForce = false);
2019-03-10 16:56:42 +03:00
virtual ~MainServer();
2019-03-10 16:56:42 +03:00
};
#endif // SERVER_H