This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
powersync-core/server/jsonrpc/jsonrpcserver.h
Michael Zanetti 02c8e6e4b4 reworked jsonrpc server.
added introspection
all calls and responses have now param validation
2014-01-20 01:13:43 +01:00

40 lines
854 B
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 JsonHandler;
class JsonRPCServer: public QObject
{
Q_OBJECT
public:
JsonRPCServer(QObject *parent = 0);
signals:
void commandReceived(const QString &targetNamespace, const QString &command, const QVariantMap &params);
private slots:
void processData(int clientId, const QByteArray &jsonData);
private:
void registerHandler(JsonHandler *handler);
void sendResponse(int clientId, int commandId, const QVariantMap &params = QVariantMap());
void sendErrorResponse(int clientId, int commandId, const QString &error);
private:
TcpServer *m_tcpServer;
QHash<QString, JsonHandler*> m_handlers;
};
#endif