network: 修复 connect 错误问题
This commit is contained in:
parent
4e5170caf8
commit
720906b0ad
|
@ -57,7 +57,6 @@ public:
|
|||
void setAi(const NineChess &chess);
|
||||
void setAi(const NineChess &chess, int depth, int time);
|
||||
|
||||
// 网络
|
||||
Server *getServer()
|
||||
{
|
||||
return server;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QtNetwork>
|
||||
|
||||
#include "client.h"
|
||||
#include "aithread.h"
|
||||
|
||||
Client::Client(QWidget *parent, uint16_t port)
|
||||
: QDialog(parent)
|
||||
|
@ -139,6 +140,8 @@ void Client::readAction()
|
|||
|
||||
currentAction = nextAction;
|
||||
statusLabel->setText(currentAction);
|
||||
// 发信号
|
||||
emit command(currentAction);
|
||||
getActionButton->setEnabled(true);
|
||||
|
||||
QTimer::singleShot(100, this, &Client::requestNewAction);
|
||||
|
|
|
@ -41,6 +41,9 @@ class Client : public QDialog
|
|||
public:
|
||||
explicit Client(QWidget *parent = nullptr, uint16_t port = 33333);
|
||||
|
||||
signals:
|
||||
void command(const QString &cmd, bool update = true);
|
||||
|
||||
private slots:
|
||||
void requestNewAction();
|
||||
void readAction();
|
||||
|
|
|
@ -73,6 +73,10 @@ GameController::GameController(GameScene & scene, QObject * parent) :
|
|||
connect(&ai2, SIGNAL(command(const QString &, bool)),
|
||||
this, SLOT(command(const QString &, bool)));
|
||||
|
||||
// 关联AI和网络类的着法命令行
|
||||
connect(ai1.getClient(), SIGNAL(command(const QString &, bool)),
|
||||
this, SLOT(command(const QString &, bool)));
|
||||
|
||||
// 安装事件过滤器监视scene的各个事件,
|
||||
// 由于我重载了QGraphicsScene,相关事件在重载函数中已设定,不必安装监视器。
|
||||
//scene.installEventFilter(this);
|
||||
|
|
Loading…
Reference in New Issue