mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
87 lines
3.0 KiB
C++
87 lines
3.0 KiB
C++
#include "connectortoserver.h"
|
|
#include <QThread>
|
|
|
|
ConnectorToServer::ConnectorToServer(QObject *parent) :
|
|
QObject(parent),
|
|
connectionThread(nullptr),
|
|
client(nullptr),
|
|
dataParser(nullptr),
|
|
sendSystem(nullptr),
|
|
recognizeSystem(nullptr)
|
|
{
|
|
initialize();
|
|
}
|
|
|
|
bool ConnectorToServer::authorizationInstructorLocal(QString login, QString password)
|
|
{
|
|
if (!client->getIsConnected())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
ClientAutorization *autorization = new ClientAutorization;
|
|
autorization->Login = login;
|
|
autorization->Password = password;
|
|
|
|
dataParser->createAuthMessage(autorization);
|
|
emit sigSendAutorization();
|
|
|
|
return true;
|
|
}
|
|
|
|
void ConnectorToServer::initialize()
|
|
{
|
|
createObjects();
|
|
|
|
bindConnection();
|
|
|
|
emit sigInitializeClient(recognizeSystem,sendSystem,connectionThread);
|
|
|
|
emit sigSetConnect(dataParser->getServerSettings(),connectionThread);
|
|
}
|
|
|
|
void ConnectorToServer::bindConnection()
|
|
{
|
|
/*
|
|
connect(recognizeSystem,&RecognizeSystem::sigStartCompare,hashComparer,&HashComparer::CompareDeltas);
|
|
connect(recognizeSystem,&RecognizeSystem::sigUpdateBytesAvailable,this,&MainWindow::updateProgress,Qt::QueuedConnection);
|
|
connect(recognizeSystem,&RecognizeSystem::sigLoadComplete,this,&MainWindow::loadComplete);
|
|
connect(recognizeSystem,&RecognizeSystem::sigNeedUpdate,this,&MainWindow::setNeedUpdate);
|
|
connect(recognizeSystem,&RecognizeSystem::sigSocketDisabled,this,&MainWindow::lostConnection);
|
|
connect(recognizeSystem,&RecognizeSystem::sigSaveLoginData,this,&MainWindow::checkLoginResult);
|
|
connect(recognizeSystem,&RecognizeSystem::sigSocketWaitForReadyRead,client,&TCPClient::waitRead,Qt::DirectConnection);
|
|
connect(recognizeSystem,&RecognizeSystem::sigServerBlocked,this,&MainWindow::serverBlocked);
|
|
|
|
connect(sendSystem,&SendSystem::sigSend,this,&MainWindow::updateProgress);
|
|
connect(sendSystem,&SendSystem::sigGetXmlAnswer,dataParser,&DataParser::slotGetXmlAnswer);
|
|
|
|
connect(client,&TCPClient::sigConnectionState,this,&MainWindow::slotConnectionState,Qt::AutoConnection);
|
|
connect(client,&TCPClient::sigServerDisconnect,this,&MainWindow::slotServerDisconnect);
|
|
*/
|
|
|
|
connect(this,&ConnectorToServer::sigInitializeClient,client,&TCPClient::initialize,Qt::AutoConnection);
|
|
connect(this,&ConnectorToServer::sigSetConnect,client,&TCPClient::setConnect,Qt::AutoConnection);
|
|
connect(this,&ConnectorToServer::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
|
|
|
|
connect(recognizeSystem,&RecognizeSystem::sigSaveLoginData,this,&ConnectorToServer::sigLoginResult);
|
|
}
|
|
|
|
void ConnectorToServer::createObjects()
|
|
{
|
|
connectionThread = new QThread;
|
|
|
|
client = new TCPClient;
|
|
client->moveToThread(connectionThread);
|
|
|
|
dataParser = new DataParser;
|
|
|
|
sendSystem = new SendSystem;
|
|
sendSystem->moveToThread(connectionThread);
|
|
|
|
recognizeSystem = new RecognizeSystem;
|
|
recognizeSystem->moveToThread(connectionThread);
|
|
|
|
connectionThread->start();
|
|
connectionThread->setPriority(QThread::HighestPriority);
|
|
}
|