forked from RetroShare/RsChess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qtchess_comm.h
93 lines (71 loc) · 1.29 KB
/
qtchess_comm.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef _QTCHESS_COMM_
#define _QTCHESS_COMM_
#define BUFFER_SIZE 1024
/*
** -- System Includes --
*/
extern "C"
{
#include <stdio.h>
}
/*
** -- Qt Includes --
*/
#include <QPointer>
#include <QTcpServer>
#include <QTcpSocket>
/*
** -- Local Includes --
*/
#include "qtchess.h"
#include "qtchess_defs.h"
class qtchess_comm: public QObject
{
Q_OBJECT
public:
/*
** -- Members --
*/
/*
** -- Methods --
*/
qtchess_comm(void);
~qtchess_comm()
{
#ifdef _DEBUG_
fprintf(stderr, "~qtchess_comm()\n");
#endif
}
bool isSet(void) const;
bool isReady(void) const;
bool isListening(void) const;
bool isConnectedRemotely(void) const;
void init(void);
void quit(void);
void sendMove(const struct move_s);
void setListen(void);
void setConnected(const bool);
void stopListening(void);
void connectRemotely(void);
void disconnectRemotely(void);
private:
/*
** -- Members --
*/
bool connected;
QTcpServer listening_sock;
QTcpSocket send_sock;
QPointer<QTcpSocket> clientConnection;
/*
** -- Methods --
*/
private slots:
void updateBoard(void);
void acceptConnection(void);
void clientDisconnected(void);
void slotClientConnected(void);
signals:
void connectedToClient(void);
void disconnectedFromClient(void);
};
#endif