mirror of https://github.com/nymea/nymea.git
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#ifndef JSONRPCSERVER_H
|
|
#define JSONRPCSERVER_H
|
|
|
|
#include "deviceclass.h"
|
|
#include "action.h"
|
|
#include "trigger.h"
|
|
|
|
#include <QObject>
|
|
#include <QVariantMap>
|
|
#include <QString>
|
|
|
|
class TcpServer;
|
|
class Device;
|
|
|
|
class JsonRPCServer: public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
JsonRPCServer(QObject *parent = 0);
|
|
|
|
signals:
|
|
void commandReceived(const QString &targetNamespace, const QString &command, const QVariantMap ¶ms);
|
|
|
|
private slots:
|
|
void processData(int clientId, const QByteArray &jsonData);
|
|
|
|
private:
|
|
void handleRulesMessage(int clientId, int commandId, const QString &method, const QVariantMap ¶ms);
|
|
void handleActionMessage(int clientId, int commandId, const QString &method, const QVariantMap ¶ms);
|
|
|
|
QVariantMap packDeviceClass(const DeviceClass &deviceClass);
|
|
QVariantMap packDevice(Device *device);
|
|
QVariantMap packTrigger(const Trigger &action);
|
|
QVariantMap packAction(const Action &action);
|
|
|
|
void sendResponse(int clientId, int commandId, const QVariantMap ¶ms = QVariantMap());
|
|
void sendErrorResponse(int clientId, int commandId, const QString &error);
|
|
|
|
private:
|
|
TcpServer *m_tcpServer;
|
|
};
|
|
|
|
#endif
|