bugfix: start connection state

This commit is contained in:
semenov
2024-09-24 09:37:10 +03:00
parent ec77072a67
commit daf1b3e3ef
5 changed files with 18 additions and 796 deletions

View File

@@ -30,15 +30,24 @@ void TCPClient::setConnect(ServerSettings *serverSettings,QThread *th)
socket->connectToHost(serverSettings->Address,serverSettings->Port.toShort());
connect(socket,&QTcpSocket::readyRead,this,&TCPClient::slotReadyRead,Qt::DirectConnection);
connect(socket,&QTcpSocket::disconnected,this,&TCPClient::setDisconnect);
connect(socket,&QTcpSocket::connected,this,&TCPClient::slotConnectNotify);
connect(this,&TCPClient::sigRecognize,recognizeSystem,&RecognizeSystem::recognize,Qt::DirectConnection);
connect(this,&TCPClient::sigSetSocket,sendSystem,&SendSystem::setSocket);
emit sigSetSocket(socket);
emit sigSendDebugLog("Try connect...");
if (socket->waitForConnected(2000))
{
connect(socket,&QTcpSocket::readyRead,this,&TCPClient::slotReadyRead,Qt::DirectConnection);
connect(socket,&QTcpSocket::disconnected,this,&TCPClient::setDisconnect);
//connect(socket,&QTcpSocket::connected,this,&TCPClient::slotConnectNotify);
connect(this,&TCPClient::sigRecognize,recognizeSystem,&RecognizeSystem::recognize,Qt::DirectConnection);
connect(this,&TCPClient::sigSetSocket,sendSystem,&SendSystem::setSocket);
emit sigSetSocket(socket);
slotConnectNotify();
}
else
{
emit sigServerDisconnect();
}
}