hyperion.ng/libsrc/jsonserver/JsonClientConnection.h

52 lines
1.2 KiB
C
Raw Normal View History

#pragma once
// stl includes
#include <string>
// Qt includes
#include <QByteArray>
#include <QTcpSocket>
// jsoncpp includes
#include <json/json.h>
// util includes
#include <utils/jsonschema/JsonSchemaChecker.h>
class JsonClientConnection : public QObject
{
Q_OBJECT
public:
JsonClientConnection(QTcpSocket * socket);
~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 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;
QByteArray _receiveBuffer;
};