#ifndef CONNECTION_H #define CONNECTION_H #include #include QT_FORWARD_DECLARE_CLASS(QWebSocket) namespace RepoIndex { class Manager; class Connection : public QObject { Q_OBJECT public: Connection(const RepoIndex::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 RepoIndex::Manager &m_alpmManager; bool m_repoInfoUpdatesRequested; bool m_groupInfoUpdatesRequested; }; } #endif // CONNECTION_H