-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.h
More file actions
59 lines (49 loc) · 1.47 KB
/
client.h
File metadata and controls
59 lines (49 loc) · 1.47 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
#ifndef CLIENT_H
#define CLIENT_H
#include <QTcpSocket>
#include <QObject>
#include <QHostAddress>
#include <QPoint>
#include <QUdpSocket>
#include <QPixmap>
class Client : public QObject
{
Q_OBJECT
private:
QTcpSocket * socket;
QUdpSocket * receiver;
QWidget *alert;
QHostAddress serverAddress;
quint16 serverPort;
quint16 clientPort;
bool isConnected;
quint16 nextBlockSize;
void sendGreeting(QString username, quint16 port);
public:
explicit Client(QTcpSocket *conn, QUdpSocket *recv, QObject *parent=0);
virtual ~Client(){}
void connectToServer(QString addrName, quint16 port, quint16 clientport, QString username);
void sendChatMessage(QString user, QString message);
void disconnectFromServer();
signals:
void connectState(bool);
void newChatMessage(QString);
void pieceMoved(quint16,QPoint);
void pieceCreated(quint16,QString,QPoint);
void pieceClear();
void gridAdjusted(int,QPoint);
void userConnected(QString,quint16);
void userDisconnected(quint16);
void pieceDeleted(quint16);
public slots:
void catchError(QAbstractSocket::SocketError);
void sendPieceMoved(quint16 pid,QPoint p);
void sendPieceCreated(QString img,QPoint p);
void sendPieceDeleted(quint16 pid);
void sendClearBoard();
void sendGridAdjusted(int size, QPoint offset);
void sendRollDice(QString user,int num, int sides);
void processSocket();
void processBroadcast();
};
#endif // CLIENT_H