-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocket.h
More file actions
47 lines (38 loc) · 1010 Bytes
/
socket.h
File metadata and controls
47 lines (38 loc) · 1010 Bytes
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
#ifndef SOCKET_H
#define SOCKET_H
#include <QTcpSocket>
#include <QDataStream>
#include <QThread>
#include <QTimer>
// divisible par 7 (size of one pixel) + 2 (size of chunck)
#define SIZE_BUFFER 4090
QT_BEGIN_NAMESPACE
class QTcpSocket;
class QNetworkSession;
QT_END_NAMESPACE
class Socket : public QObject
{
Q_OBJECT
public:
Socket(QString ip, int port);
~Socket();
void start(const QPixmap &pixmap);
public slots:
void createSocket();
bool writeData(QByteArray data);
void start();
private slots:
void readFortune();
QByteArray IntToArray(qint32 source);
void displayError(QAbstractSocket::SocketError socketError);
private:
QTcpSocket *tcpSocket;
QThread cThread;
QDataStream in;
QString currentFortune;
QNetworkSession *networkSession;
Socket *socket;
QString _ip;
int _port;
};
#endif // SOCKET_H