-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtcpapp.h
More file actions
60 lines (52 loc) · 1.63 KB
/
tcpapp.h
File metadata and controls
60 lines (52 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef TCPAPP_H
#define TCPAPP_H
#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
#include <QComboBox>
#include <QListWidget>
#include <QVector>
#include <QQueue>
class TCPApp : public QObject
{
Q_OBJECT
public:
explicit TCPApp(QWidget *tab, QObject *parent = nullptr);
void updateUI();
void initClient();
void closeClient();
QString initServer();
QString closeServer();
QString sendData(const QByteArray &data);
QString listDisconnect();
signals:
void errorOccurred(QString errorStr);
void stateChanged(QString state);
void connected(QString qstrSender);
void disconnected(QString qstrSender);
void hasRecved(QByteArray data, QString address, int enumTunnel);
void bytesSended(qint64 bytes, QString address);
public slots:
void onError(QAbstractSocket::SocketError socketError);
void onBytesSended(qint64 bytes);
void onStateChanged(QAbstractSocket::SocketState socketState);
void readPendingData();
void acceptConnection();
protected:
void initUI();
void connectSlot(QTcpSocket *pClient);
void listAppendConn(QTcpSocket *pClient);
void listRemoveConn(QTcpSocket *pClient);
QWidget *m_pTab = nullptr;
QTcpServer *m_pServer = nullptr;
QTcpSocket *m_pClient = nullptr;
QVector<QTcpSocket*> m_qvClient;
public:
QComboBox *m_pcbxHostIP = nullptr;
QComboBox *m_pcbxHostPort = nullptr;
QComboBox *m_pcbxListenIP = nullptr;
QComboBox *m_pcbxListenPort = nullptr;
QListWidget *m_plistTCPConn = nullptr;
QQueue<QByteArray> m_sendData;
};
#endif // TCPAPP_H