File indexing completed on 2024-12-08 04:33:10

0001 /*
0002 
0003  * SPDX-FileCopyrightText: 2020 Alessandro Ambrosano <alessandro.ambrosano@gmail.com>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  *
0007  */
0008 
0009 #pragma once
0010 
0011 #include <QObject>
0012 
0013 #include "libruqolacore_export.h"
0014 
0015 class DDPClient;
0016 
0017 /**
0018  * @class DDPManager
0019  * @brief Abstract class describing the interface for classes that may subscribe to DDP events
0020  *   and call DDP methods.
0021  */
0022 class LIBRUQOLACORE_EXPORT DDPManager : public QObject
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     explicit DDPManager(DDPClient *ddpClient, QObject *parent = nullptr);
0028     ~DDPManager() override = default;
0029 
0030     void processMethodResponse(int opId, const QJsonObject &response);
0031     void processSubscriptionResult(int subId, const QJsonObject &result);
0032 
0033     [[nodiscard]] DDPClient *ddpClient() const;
0034 
0035 protected:
0036     DDPClient *mDdpClient = nullptr;
0037 
0038 private:
0039     virtual void processMethodResponseImpl(int opId, const QJsonObject &response) = 0;
0040     virtual void processSubscriptionResultImpl(int subId, const QJsonObject &result) = 0;
0041 };