83 lines
1.6 KiB
C
Raw Normal View History

2019-02-13 13:03:40 +03:00
#ifndef CLIENT_CP_H
#define CLIENT_CP_H
#include "clientprotocol_global.h"
#include "clientprotocol.h"
#include <QObject>
class QTcpSocket;
2019-02-13 14:28:42 +03:00
class Player;
class BaseItem;
2019-03-02 00:10:43 +03:00
class testSankeServer;
2019-02-13 13:03:40 +03:00
namespace ClientProtocol {
class CLIENTPROTOCOLSHARED_EXPORT Client: public QObject
{
Q_OBJECT
private:
QTcpSocket *_destination;
Package _downloadPackage;
bool _online = false;
QByteArray _token;
2019-03-01 15:26:45 +03:00
int currentIndex = 0;
2019-03-01 07:56:15 +03:00
QVariantMap _requestsMap[256];
2019-03-01 15:26:45 +03:00
bool receiveData(QVariantMap map);
2019-03-01 07:56:15 +03:00
void setOnline(bool newStatus);
2019-03-02 00:10:43 +03:00
bool sendPackage(const Package& pkg);
2019-02-13 13:03:40 +03:00
private slots:
void incommingData();
public:
explicit Client(QObject * ptr = nullptr);
2019-02-13 14:28:42 +03:00
/**
* @brief login - register or login a user
* @param gmail - gmail of user
* @param pass - hash of pass of user
* @param error - error ( if all good this variable is empty)
2019-02-15 23:36:59 +03:00
* @return
2019-02-13 14:28:42 +03:00
*/
2019-02-15 23:36:59 +03:00
bool login(const QString& gmail, const QByteArray &pass);
2019-02-13 14:28:42 +03:00
/**
* @brief updateData
* @return true if refresh seсcessfully completed
*/
bool updateData();
/**
* @brief savedata
* @param gameData - data of lvl
* @return true if all good
*/
bool savaData(QVariantMap gameData);
2019-02-13 14:28:42 +03:00
/**
* @brief getItem
* @param id of item
* @return item data
*/
bool getItem(int id);
2019-02-13 14:28:42 +03:00
/**
* @brief isOnline
* @return true if player online
*/
bool isOnline() const;
2019-03-02 00:10:43 +03:00
friend class ::testSankeServer;
2019-02-13 13:03:40 +03:00
signals:
void sigIncommingData(const QVariantMap& map);
void onlineChanged(bool);
2019-02-13 13:03:40 +03:00
};
}
#endif // CLIENT_CP_H