-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTcpClient.h
42 lines (34 loc) · 822 Bytes
/
TcpClient.h
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
#ifndef MYTCPCLIENT_H
#define MYTCPCLIENT_H
#include <QObject>
#include <QTcpSocket>
#include <QTimer>
#include "data/data.h"
#include "data/BoardModel.h"
#include "data/Message.h"
class TcpClient : public QObject
{
Q_OBJECT
public:
TcpClient();
bool isConnected();
void connectToServer();
void disconnectFromServer();
void sendMessage(Message msg);
signals:
void report(QString);
void receivedData(QByteArray data);
void connected();
void disconnected();
void error(QAbstractSocket::SocketError);
private slots:
void onSocketConnected();
void onSocketDisconnected();
void onReadyRead();
void onSocketError(QAbstractSocket::SocketError err);
void onFlushTimerTick();
private:
QTcpSocket socket;
QTimer flush_timer;
};
#endif // MYTCPCLIENT_H