Refactor tcpserver into multiple files
This commit is contained in:
parent
e3b6d5c3a6
commit
59b55d1868
10 changed files with 486 additions and 446 deletions
33
src/service/tcpclient.h
Normal file
33
src/service/tcpclient.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef TCPSERVER_CLIENT_H
|
||||
#define TCPSERVER_CLIENT_H
|
||||
|
||||
#include <QTcpSocket>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "service.h"
|
||||
|
||||
class TcpClient : public Service
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QTcpSocket* socket;
|
||||
client_state_t state = STATE_IDLE;
|
||||
long long recievebytes = 0;
|
||||
QByteArray buffer;
|
||||
|
||||
public:
|
||||
TcpClient(QObject* parent = nullptr);
|
||||
~TcpClient();
|
||||
virtual bool launch(const QHostAddress &address = QHostAddress::Any, quint16 port = 0) override;
|
||||
virtual void sendJson(const QJsonObject& json) override;
|
||||
|
||||
protected:
|
||||
virtual void processIncomeingJson(const QByteArray& jsonbytes) override;
|
||||
|
||||
private slots:
|
||||
void socketReadyRead();
|
||||
void processComand(const QByteArray& command);
|
||||
};
|
||||
|
||||
#endif // TCPSERVER_CLIENT_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue