hyperion.ng/libsrc/jsonserver/JsonClientConnection.h

53 lines
891 B
C
Raw Normal View History

#pragma once
// Qt includes
#include <QString>
#include <QByteArray>
2018-12-27 23:11:32 +01:00
#include <QJsonObject>
// util includes
#include <utils/Logger.h>
2018-12-27 23:11:32 +01:00
class JsonAPI;
class QTcpSocket;
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
///
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
signals:
void connectionClosed();
public slots:
qint64 sendMessage(QJsonObject);
private slots:
2013-09-09 04:54:13 +02:00
///
/// Slot called when new data has arrived
///
void readRequest();
void disconnected();
private:
QTcpSocket* _socket;
2018-12-27 23:11:32 +01:00
/// new instance of JsonAPI
JsonAPI * _jsonAPI;
2013-09-09 04:54:13 +02:00
/// The buffer used for reading data from the socket
QByteArray _receiveBuffer;
/// The logger instance
Logger * _log;
};