mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
feat: before threading
This commit is contained in:
@@ -21,20 +21,21 @@ void RecognizeSystem::Initialize(UpdateController *updateController,DataParser *
|
||||
{
|
||||
this->updateController = updateController;
|
||||
this->dataParser = dataParser;
|
||||
connect(this,&RecognizeSystem::SaveLoginData,dataParser,&DataParser::CreateAuthData);
|
||||
}
|
||||
|
||||
void RecognizeSystem::SetSocket(QTcpSocket *socket)
|
||||
{
|
||||
this->socket = socket;
|
||||
}
|
||||
|
||||
void RecognizeSystem::Recognize()
|
||||
void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
|
||||
while(socket->bytesAvailable())
|
||||
{
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
qDebug() << "BUSY, WAIT";
|
||||
}
|
||||
|
||||
if(packetType == PacketType::TYPE_NONE){ //определение первичного пакета
|
||||
|
||||
stream.startTransaction();
|
||||
@@ -109,19 +110,19 @@ void RecognizeSystem::Recognize()
|
||||
emit onSendDebugLog(Tools::GetTime() + "CLIENT: filePath, fileSize - FAIL commitTransaction");
|
||||
|
||||
if (!socket->waitForReadyRead(TCP_READ_TIMEOUT)) {
|
||||
emit onSendDebugLog(Tools::GetTime() + "CLIENT: ERROR! readyRead timeout - filePath, fileSize!!!");
|
||||
return;
|
||||
}
|
||||
emit onSendDebugLog(Tools::GetTime() + "CLIENT: ERROR! readyRead timeout - filePath, fileSize!!!");
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
filePath = Tools::CreateFullPath(filePath);
|
||||
|
||||
emit onSendDebugLog("CLIENT: filesize: " + QString::number(fileSize));
|
||||
emit onSendDebugLog("CLIENT: filePath: " + filePath);
|
||||
emit onSendDebugLog("CLIENT: filesize: " + QString::number(fileSize));
|
||||
emit onSendDebugLog("CLIENT: filePath: " + filePath);
|
||||
|
||||
socket->waitForReadyRead(100);
|
||||
emit SocketWaitForReadyRead(100);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -247,6 +248,10 @@ void RecognizeSystem::Recognize()
|
||||
stream.startTransaction();
|
||||
stream >> array;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
continue;
|
||||
}
|
||||
|
||||
XMLParser(array);
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
@@ -260,33 +265,62 @@ void RecognizeSystem::XMLParser(QByteArray array)
|
||||
{
|
||||
QXmlStreamReader xmlReader(array);
|
||||
|
||||
xmlReader.readNext();
|
||||
xmlReader.readNext();
|
||||
|
||||
while(!xmlReader.atEnd())
|
||||
while(!xmlReader.atEnd())
|
||||
{
|
||||
if(!xmlReader.isStartElement()) {
|
||||
xmlReader.readNext();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(xmlReader.name() == "ServerNotify")
|
||||
{
|
||||
if(!xmlReader.isStartElement()) {
|
||||
xmlReader.readNext();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(xmlReader.name() == "ServerNotify")
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
|
||||
if(name == "Code"){
|
||||
if (value == "END"){
|
||||
if(name == "Code"){
|
||||
if (value == "END"){
|
||||
|
||||
emit SockedDisabled();
|
||||
emit SockedDisabled();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xmlReader.readNext();
|
||||
}
|
||||
|
||||
if(xmlReader.name() == "ServerAuthorization"){
|
||||
|
||||
ServerAuthorization *serverAuth = new ServerAuthorization;
|
||||
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
|
||||
if (name == "Result"){
|
||||
serverAuth->Result = value == "true" ? true : false;
|
||||
}
|
||||
|
||||
if (name == "InstructorName"){
|
||||
serverAuth->InstructorName = value;
|
||||
}
|
||||
|
||||
if (name == "ClientName"){
|
||||
serverAuth->ClientName = value;
|
||||
}
|
||||
|
||||
if (name == "AccessType"){
|
||||
serverAuth->AccessType = value;
|
||||
}
|
||||
}
|
||||
|
||||
emit SaveLoginData(serverAuth);
|
||||
}
|
||||
|
||||
xmlReader.readNext();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user