bugfix: long connection

This commit is contained in:
semenov
2024-09-10 12:15:41 +03:00
parent 429ccfb185
commit d3e03d6d91
15 changed files with 53 additions and 109 deletions

View File

@@ -30,21 +30,11 @@ void TCPClient::setConnect(ServerSettings *serverSettings)
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);
socket->connectToHost(serverSettings->Address,serverSettings->Port.toShort());
emit sigSendDebugLog("Try connect...");
socket->waitForReadyRead();
if(socket->state() != QTcpSocket::ConnectedState){
emit sigSendDebugLog("Connect invalid");
emit sigConnectionState(false);
return;
}else{
emit sigSendDebugLog("Connect complete");
emit sigConnectionState(true);
}
}
void TCPClient::sendClientAutorization()
@@ -167,6 +157,18 @@ void TCPClient::slotMessageEntered(QString message)
}
}
void TCPClient::slotConnectNotify()
{
if(socket->state() != QTcpSocket::ConnectedState){
emit sigSendDebugLog("Connect invalid");
emit sigConnectionState(false);
return;
}else{
emit sigSendDebugLog("Connect complete");
emit sigConnectionState(true);
}
}
void TCPClient::slotReadyRead()
{
if(!socket){