hyperion.ng/libsrc/jsonserver/JsonClientConnection.h

55 lines
928 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;
2019-01-27 13:41:21 +01:00
class WebSocketClient;
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
///
JsonClientConnection(QTcpSocket * socket);
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;
2019-01-27 13:41:21 +01:00
WebSocketClient* _websocketClient;
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;
};