repoindex/lib/network/connection.h

48 lines
1.2 KiB
C
Raw Normal View History

2015-08-10 22:46:01 +02:00
#ifndef CONNECTION_H
#define CONNECTION_H
#include <QObject>
#include <QJsonValue>
2015-08-10 22:46:01 +02:00
#include <map>
QT_FORWARD_DECLARE_CLASS(QWebSocket)
namespace RepoIndex {
2015-08-10 22:46:01 +02:00
class Manager;
2015-08-10 22:46:01 +02:00
class Connection : public QObject
{
Q_OBJECT
public:
2016-02-25 22:53:33 +01:00
Connection(Manager &alpmManager, QWebSocket *socket, QObject *parent = nullptr);
2015-08-10 22:46:01 +02:00
2020-03-08 14:12:22 +01:00
private Q_SLOTS:
2015-08-10 22:46:01 +02:00
void processTextMessage(const QString &message);
void processBinaryMessage(const QByteArray &message);
void socketDisconnected();
2015-09-04 14:37:01 +02:00
void sendResult(const QJsonValue &what, const QJsonValue &id, const QJsonValue &value);
2016-02-25 22:53:33 +01:00
void sendResults(const QJsonValue &what, const QJsonValue &id, const QJsonValue &values);
void updatedAvailable();
2015-08-10 22:46:01 +02:00
private:
void sendJson(const QJsonObject &obj);
void sendError(const QString &msg, const QJsonValue &id = QJsonValue());
2015-08-10 22:46:01 +02:00
void handleQuery(const QJsonObject &obj);
void handleCmd(const QJsonObject &obj);
2015-09-29 21:52:30 +02:00
template<class Lookup, typename... Args> void performLookup(const QJsonObject &request, Args &&...args);
2015-08-10 22:46:01 +02:00
QWebSocket *m_socket;
RepoIndex::Manager &m_manager;
2015-08-10 22:46:01 +02:00
bool m_repoInfoUpdatesRequested;
bool m_groupInfoUpdatesRequested;
};
2016-02-25 22:53:33 +01:00
2015-08-10 22:46:01 +02:00
}
#endif // CONNECTION_H