Files

46 lines
964 B
C++
Raw Permalink Normal View History

2020-12-26 15:03:51 +03:00
#ifndef MANAGEMENTSERVER_H
#define MANAGEMENTSERVER_H
#include <QAbstractSocket>
2021-01-07 19:10:24 +03:00
#include <QPointer>
#include <QSharedPointer>
2020-12-26 15:03:51 +03:00
#include <QString>
class QTcpServer;
class QTcpSocket;
class ManagementServer : public QObject
{
Q_OBJECT
public:
explicit ManagementServer(QObject *parent = nullptr);
~ManagementServer();
bool start(const QString& host, unsigned int port);
void stop();
bool isOpen() const;
QString readLine();
qint64 writeCommand(const QString& message);
2021-01-07 19:10:24 +03:00
QPointer<QTcpSocket> socket() const;
2020-12-26 15:03:51 +03:00
signals:
void readyRead();
void serverStarted();
protected slots:
void onAcceptError(QAbstractSocket::SocketError socketError);
void onNewConnection();
void onReadyRead();
void onSocketDisconnected();
void onSocketError(QAbstractSocket::SocketError socketError);
protected:
2021-01-07 19:10:24 +03:00
QSharedPointer<QTcpServer> m_tcpServer;
QPointer<QTcpSocket> m_socket;
2020-12-26 15:03:51 +03:00
};
#endif // MANAGEMENTSERVER_H