2013-08-17 15:39:29 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// stl includes
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
// Qt includes
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QTcpSocket>
|
|
|
|
|
|
|
|
// jsoncpp includes
|
|
|
|
#include <json/json.h>
|
|
|
|
|
2013-08-18 12:21:07 +02:00
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/Hyperion.h>
|
|
|
|
|
2013-08-17 19:20:19 +02:00
|
|
|
// util includes
|
|
|
|
#include <utils/jsonschema/JsonSchemaChecker.h>
|
|
|
|
|
2013-08-18 20:55:59 +02:00
|
|
|
class ImageProcessor;
|
|
|
|
|
2013-08-17 15:39:29 +02:00
|
|
|
class JsonClientConnection : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2013-08-18 12:21:07 +02:00
|
|
|
JsonClientConnection(QTcpSocket * socket, Hyperion * hyperion);
|
2013-08-17 15:39:29 +02:00
|
|
|
~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();
|
2013-08-17 15:39:29 +02:00
|
|
|
|
|
|
|
void sendMessage(const Json::Value & message);
|
2013-08-18 12:21:07 +02:00
|
|
|
void sendSuccessReply();
|
2013-08-17 15:39:29 +02:00
|
|
|
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-17 15:39:29 +02:00
|
|
|
|
2013-08-18 12:02:17 +02:00
|
|
|
private:
|
|
|
|
QTcpSocket * _socket;
|
2013-08-17 19:20:19 +02:00
|
|
|
|
2013-08-18 20:55:59 +02:00
|
|
|
ImageProcessor * _imageProcessor;
|
|
|
|
|
2013-08-18 12:21:07 +02:00
|
|
|
Hyperion * _hyperion;
|
|
|
|
|
2013-08-17 15:39:29 +02:00
|
|
|
QByteArray _receiveBuffer;
|
|
|
|
};
|