mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
70 lines
1.8 KiB
C++
70 lines
1.8 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(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);
|
|
}
|