mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
feat: add disconnect behaviour
This commit is contained in:
@@ -31,6 +31,9 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
|
||||
while(socket->bytesAvailable())
|
||||
{
|
||||
|
||||
if (socket->state() != QTcpSocket::ConnectedState) return;
|
||||
|
||||
if(packetType == PacketType::TYPE_NONE){ //определение первичного пакета
|
||||
|
||||
stream.startTransaction();
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include "Core\recognizesystem.h"
|
||||
#include "Core\tools.h"
|
||||
#include "Core\updatecontroller.h"
|
||||
#include "Core\UpdateController.h"
|
||||
#include "Core\externalexecuter.h"
|
||||
|
||||
class UpdateController;
|
||||
@@ -37,6 +37,7 @@ signals:
|
||||
void sigSendDebugLog(QString message);
|
||||
void sigRecognize(QTcpSocket *socket);
|
||||
void sigConnectionState(bool flag);
|
||||
void sigServerDisconnect();
|
||||
QByteArray sigGetXmlAnswer(QString);
|
||||
|
||||
public slots:
|
||||
|
||||
Reference in New Issue
Block a user