hyperion.ng/libsrc/jsonserver/JsonClientConnection.h

62 lines
1.3 KiB
C
Raw Normal View History

#pragma once
// stl includes
#include <string>
// Qt includes
#include <QByteArray>
#include <QTcpSocket>
// jsoncpp includes
#include <json/json.h>
// Hyperion includes
#include <hyperion/Hyperion.h>
// util includes
#include <utils/jsonschema/JsonSchemaChecker.h>
2013-08-18 20:55:59 +02:00
class ImageProcessor;
class JsonClientConnection : public QObject
{
Q_OBJECT
public:
JsonClientConnection(QTcpSocket * socket, Hyperion * hyperion);
~JsonClientConnection();
signals:
void connectionClosed(JsonClientConnection * connection);
private slots:
void readData();
void socketClosed();
private:
void handleMessage(const std::string & message);
2013-08-18 12:02:17 +02:00
void handleColorCommand(const Json::Value & message);
void handleImageCommand(const Json::Value & message);
void handleServerInfoCommand(const Json::Value & message);
void handleClearCommand(const Json::Value & message);
void handleClearallCommand(const Json::Value & message);
void handleTransformCommand(const Json::Value & message);
void handleNotImplemented();
void sendMessage(const Json::Value & message);
void sendSuccessReply();
void sendErrorReply(const std::string & error);
private:
2013-08-18 12:02:17 +02:00
bool checkJson(const Json::Value & message, const QString &schemaResource, std::string & errors);
2013-08-18 12:02:17 +02:00
private:
QTcpSocket * _socket;
2013-08-18 20:55:59 +02:00
ImageProcessor * _imageProcessor;
Hyperion * _hyperion;
QByteArray _receiveBuffer;
};