feat: add disconnect behaviour

This commit is contained in:
semenov
2024-09-10 17:47:52 +03:00
parent d3e03d6d91
commit e9cd136238
17 changed files with 110 additions and 61 deletions

View File

@@ -1,5 +1,5 @@
#include "tcpclient.h"
#include "updatecontroller.h"
#include "UpdateController.h"
#include "externalexecuter.h"
#include <QDir>
@@ -7,7 +7,10 @@
TCPClient::TCPClient(QObject *parent) :
QObject(parent)
{
socket = NULL;
//socket = NULL;
socket = new QTcpSocket();
socket->setParent(this);
socket->moveToThread(this->thread());
}
void TCPClient::initialize(RecognizeSystem *recognize,ExternalExecuter *externalExecuter)
@@ -15,6 +18,7 @@ void TCPClient::initialize(RecognizeSystem *recognize,ExternalExecuter *external
this->recognizeSystem = recognize;
this->externalExecuter = externalExecuter;
emit sigSendDebugLog(Tools::getTime() + " Client started");
}
@@ -26,8 +30,6 @@ void TCPClient::setConnect(ServerSettings *serverSettings)
return;
}
socket = new QTcpSocket(this);
connect(socket,&QTcpSocket::readyRead,this,&TCPClient::slotReadyRead,Qt::DirectConnection);
connect(socket,&QTcpSocket::disconnected,this,&TCPClient::setDisconnect);
connect(socket,&QTcpSocket::connected,this,&TCPClient::slotConnectNotify);
@@ -98,6 +100,7 @@ void TCPClient::sendUnityConnect()
void TCPClient::setDisconnect()
{
socket->disconnect();
emit sigServerDisconnect();
emit sigSendDebugLog("Server disabled");
}