feat: connection thread

This commit is contained in:
semenov
2024-08-20 09:13:31 +03:00
parent c79faae730
commit d04b281987
6 changed files with 13 additions and 11 deletions

View File

@@ -22,9 +22,9 @@ void TCPClient::SetConnect(ServerSettings *serverSettings)
{
socket = new QTcpSocket(this);
connect(socket,&QTcpSocket::readyRead,this,&TCPClient::onReadyRead);
connect(socket,&QTcpSocket::readyRead,this,&TCPClient::onReadyRead,Qt::DirectConnection);
connect(socket,&QTcpSocket::disconnected,this,&TCPClient::SetDisconnect);
connect(this,&TCPClient::Recognize,recognizeSystem,&RecognizeSystem::Recognize);
connect(this,&TCPClient::Recognize,recognizeSystem,&RecognizeSystem::Recognize,Qt::DirectConnection);
socket->connectToHost(serverSettings->Address,serverSettings->Port.toShort());
emit onSendDebugLog("Try connect...");

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2024-08-16T17:18:14. -->
<!-- Written by QtCreator 4.11.1, 2024-08-19T13:28:10. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -22,9 +22,8 @@ void MainWindow::Initialize()
ui->startButton->setEnabled(false);
updateControllerThread = new QThread;
updateControllerThread->setPriority(QThread::LowPriority);
connectionThread = new QThread;
connectionThread->setPriority(QThread::HighestPriority);
client = new TCPClient;
client->moveToThread(connectionThread);
@@ -44,17 +43,20 @@ void MainWindow::Initialize()
connect(recognizeSystem,&RecognizeSystem::onSendDebugLog,this,&MainWindow::DebugLog);
connect(recognizeSystem,&RecognizeSystem::SockedDisabled,this,&MainWindow::LostConnection);
connect(recognizeSystem,&RecognizeSystem::SaveLoginData,this,&MainWindow::CheckLoginResult);
connect(recognizeSystem,&RecognizeSystem::SocketWaitForReadyRead,client,&TCPClient::WaitRead);
connect(recognizeSystem,&RecognizeSystem::SocketWaitForReadyRead,client,&TCPClient::WaitRead,Qt::AutoConnection);
connectionThread->start();
updateControllerThread->start();
connect(client,&TCPClient::onSendDebugLog,this,&MainWindow::DebugLog);
updateControllerThread->setPriority(QThread::LowPriority);
connectionThread->setPriority(QThread::HighestPriority);
connect(this,&MainWindow::onInitializeClient,client,&TCPClient::Initialize);
connect(this,&MainWindow::onSetConnect,client,&TCPClient::SetConnect);
connect(this,&MainWindow::onSendMessage,client,&TCPClient::MessageEntered);
connect(this,&MainWindow::SendClientAuthorization,client,&TCPClient::SendClientAutorization);
connect(client,&TCPClient::onSendDebugLog,this,&MainWindow::DebugLog,Qt::AutoConnection);
connect(this,&MainWindow::onInitializeClient,client,&TCPClient::Initialize,Qt::AutoConnection);
connect(this,&MainWindow::onSetConnect,client,&TCPClient::SetConnect,Qt::AutoConnection); //умирает
connect(this,&MainWindow::onSendMessage,client,&TCPClient::MessageEntered,Qt::AutoConnection);
connect(this,&MainWindow::SendClientAuthorization,client,&TCPClient::SendClientAutorization,Qt::AutoConnection);
connect(this,&MainWindow::onCalculateHash,updateController,&UpdateController::CalculateHash);