hyperion.ng/libsrc/jsonserver/JsonClientConnection.h

52 lines
869 B
C
Raw Normal View History

#pragma once
// Qt includes
#include <QString>
#include <QByteArray>
// util includes
#include <utils/Logger.h>
class JsonProcessor;
class QTcpSocket;
2013-09-09 04:54:13 +02:00
///
/// The Connection object created by \a JsonServer when a new connection is establshed
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;
/// new instance of JsonProcessor
JsonProcessor * _jsonProcessor;
2013-09-09 04:54:13 +02:00
/// The buffer used for reading data from the socket
QByteArray _receiveBuffer;
/// The logger instance
Logger * _log;
};