repoindex/network/connection.h

45 lines
1023 B
C++

#ifndef CONNECTION_H
#define CONNECTION_H
#include <QObject>
#include <map>
QT_FORWARD_DECLARE_CLASS(QWebSocket)
namespace PackageManagement {
class Manager;
}
namespace Network {
class Connection : public QObject
{
Q_OBJECT
public:
Connection(const PackageManagement::Manager &alpmManager, QWebSocket *socket, QObject *parent = nullptr);
private slots:
void processTextMessage(const QString &message);
void processBinaryMessage(const QByteArray &message);
void socketDisconnected();
void sendResult(const QJsonValue &what, const QJsonValue &id, const QJsonValue &value);
void sendResults(const QJsonValue &what, const QJsonValue &id, const QJsonArray &values);
private:
void sendJson(const QJsonObject &obj);
void sendError(const QString &msg);
void handleQuery(const QJsonObject &obj);
QWebSocket *m_socket;
const PackageManagement::Manager &m_alpmManager;
bool m_repoInfoUpdatesRequested;
bool m_groupInfoUpdatesRequested;
};
}
#endif // CONNECTION_H