MCPcopy Create free account
hub / github.com/XMuli/ChineseChess / NetworkGame

Method NetworkGame

NetworkGame.cpp:109–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107} // namespace
108
109NetworkGame::NetworkGame(bool isServer)
110{
111 m_bIsTcpServer = isServer;
112 setPerspectiveFlipped(!isServer);
113 m_tcpServer = NULL;
114 m_tcpSocket = NULL;
115
116 QNetworkProxyFactory::setUseSystemConfiguration(false);
117
118 initUI();
119
120 if(m_bIsTcpServer) //作为服务器端
121 {
122 m_tcpServer = new QTcpServer(this);
123 onBtnTryConnect();
124 connect(m_tcpServer, SIGNAL(newConnection()),this, SLOT(slotNewConnection()));
125 }
126 else //作为客户端
127 {
128 m_tcpSocket = new QTcpSocket(this);
129 connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(slotRecv()));
130 }
131
132 connect(ChessBoard::ui->btnTcpConnect, &QPushButton::released, this, &NetworkGame::onBtnTryConnect);
133 connect(ChessBoard::ui->comboIp, &QComboBox::currentTextChanged, this, &NetworkGame::handleServerEndpointChange);
134 connect(ChessBoard::ui->sbPort, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &NetworkGame::handleServerEndpointChange);
135}
136
137void NetworkGame::initUI()
138{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected