2013-08-17 15:39:29 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// Qt includes
|
2017-03-04 22:17:42 +01:00
|
|
|
#include <QString>
|
2017-11-20 00:06:45 +01:00
|
|
|
#include <QByteArray>
|
2018-12-27 23:11:32 +01:00
|
|
|
#include <QJsonObject>
|
2013-08-18 12:21:07 +02:00
|
|
|
|
2013-08-17 19:20:19 +02:00
|
|
|
// util includes
|
2016-07-11 17:08:22 +02:00
|
|
|
#include <utils/Logger.h>
|
2017-09-16 09:08:21 +02:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
class JsonAPI;
|
2017-11-20 00:06:45 +01:00
|
|
|
class QTcpSocket;
|
2017-09-16 09:08:21 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2019-01-27 13:41:21 +01:00
|
|
|
/// The Connection object created by \a JsonServer when a new connection is established
|
2013-08-31 14:36:54 +02:00
|
|
|
///
|
2013-08-17 15:39:29 +02:00
|
|
|
class JsonClientConnection : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Constructor
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @param socket The Socket object for this connection
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2020-08-08 13:09:15 +02:00
|
|
|
JsonClientConnection(QTcpSocket * socket, bool localConnection);
|
2013-08-31 14:36:54 +02:00
|
|
|
|
2017-11-20 00:06:45 +01:00
|
|
|
signals:
|
|
|
|
void connectionClosed();
|
2013-08-17 15:39:29 +02:00
|
|
|
|
2016-08-11 07:13:55 +02:00
|
|
|
public slots:
|
2017-08-06 21:50:30 +02:00
|
|
|
qint64 sendMessage(QJsonObject);
|
2016-08-11 07:13:55 +02:00
|
|
|
|
2013-08-17 15:39:29 +02:00
|
|
|
private slots:
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Slot called when new data has arrived
|
|
|
|
///
|
2017-11-20 00:06:45 +01:00
|
|
|
void readRequest();
|
2013-08-17 15:39:29 +02:00
|
|
|
|
2017-11-20 00:06:45 +01:00
|
|
|
void disconnected();
|
2016-09-07 20:10:37 +02:00
|
|
|
|
2013-08-17 15:39:29 +02:00
|
|
|
private:
|
2017-11-20 00:06:45 +01:00
|
|
|
QTcpSocket* _socket;
|
2018-12-27 23:11:32 +01:00
|
|
|
/// new instance of JsonAPI
|
|
|
|
JsonAPI * _jsonAPI;
|
2016-08-15 22:32:01 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The buffer used for reading data from the socket
|
2013-08-17 15:39:29 +02:00
|
|
|
QByteArray _receiveBuffer;
|
2017-06-24 11:52:22 +02:00
|
|
|
|
2016-08-11 07:13:55 +02:00
|
|
|
/// The logger instance
|
2016-07-11 17:08:22 +02:00
|
|
|
Logger * _log;
|
2013-08-17 15:39:29 +02:00
|
|
|
};
|