hyperion.ng/libsrc/jsonserver/JsonClientConnection.h
2013-08-18 20:55:59 +02:00

62 lines
1.3 KiB
C++

#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>
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);
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:
bool checkJson(const Json::Value & message, const QString &schemaResource, std::string & errors);
private:
QTcpSocket * _socket;
ImageProcessor * _imageProcessor;
Hyperion * _hyperion;
QByteArray _receiveBuffer;
};