-
Notifications
You must be signed in to change notification settings - Fork 4
/
Network.h
56 lines (47 loc) · 1.17 KB
/
Network.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef NETWORK_H
#define NETWORK_H
#include <QObject>
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QTcpSocket>
#include <QtNetwork/QUdpSocket>
#include <QList>
#include "Common.h"
class Network : public QObject
{
Q_OBJECT
public:
explicit Network(QObject *parent = 0);
~Network();
//void broadcastToHost();
//void join(QHostAddress addr);
void join(const QString& ip);
void askRegret();
void respondRegret(bool agree);
void notifyStart(Qizi otherQizi, bool firstDrop);
void notifyDrop(Step step);
void close();
QList<QHostAddress> localAddresses();
protected:
void init();
signals:
//void receiveHost(QHostAddress addr);
void otherConnected();
void joinGame(Qizi qizi, bool firstDrop);
void otherDrops(Step step);
void otherAsksRegret();
void otherRespondsRegret(bool agree);
protected slots:
void onClientArrives();
void onTcpRead();
//void onUdpRead();
protected:
QList<QHostAddress> m_myAddresses;
//QList<QHostAddress> m_broadcasts;
quint16 m_tcpPort;
QTcpServer* m_tcpServer;
QTcpSocket* m_clientSocket;
QTcpSocket* m_mySocket;
//QUdpSocket* m_udpSocket;
bool m_isHost;
};
#endif // NETWORK_H