-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathNetworkGame.h
More file actions
executable file
·41 lines (32 loc) · 1.1 KB
/
NetworkGame.h
File metadata and controls
executable file
·41 lines (32 loc) · 1.1 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
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2019-2026 XMuli & Contributors
// SPDX-GitHub: https://github.com/XMuli/ChineseChess
// SPDX-Author: XMuli <xmulitech@gmail.com>
#ifndef NETWORKGAME_H
#define NETWORKGAME_H
#include "ChessBoard.h"
#include <QTcpServer>
#include <QTcpSocket>
//定义协议:
//第一个字节:表示点击的棋子ID;第二个字节:表示点击的行row,第三个字节:表示点击的列col
class NetworkGame : public ChessBoard
{
Q_OBJECT
public:
NetworkGame(bool isServer);
~NetworkGame() = default;
void initUI();
void clickPieces(int checkedID, int& row, int& col) override;
void back() override;
public slots:
void slotNewConnection();
void slotRecv();
void onBtnTryConnect();
void handleServerEndpointChange();
private:
void populateLocalIpChoices(const QStringList& candidates = QStringList(), const QString& preferredIp = QString());
QString currentIpText() const;
QTcpServer* m_tcpServer;
QTcpSocket* m_tcpSocket;
};
#endif // NETWORKGAME_H