network: 修复 connect 错误问题

This commit is contained in:
CalciteM 2019-07-29 00:26:10 +08:00
parent 4e5170caf8
commit 720906b0ad
4 changed files with 10 additions and 1 deletions

View File

@ -57,7 +57,6 @@ public:
void setAi(const NineChess &chess);
void setAi(const NineChess &chess, int depth, int time);
// 网络
Server *getServer()
{
return server;

View File

@ -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);

View File

@ -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();

View File

@ -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);