mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
feat: send xml answer
This commit is contained in:
@@ -17,9 +17,10 @@ RecognizeSystem::~RecognizeSystem()
|
||||
|
||||
}
|
||||
|
||||
void RecognizeSystem::Initialize(UpdateController *updateController)
|
||||
void RecognizeSystem::Initialize(UpdateController *updateController,DataParser *dataParser)
|
||||
{
|
||||
this->updateController = updateController;
|
||||
this->dataParser = dataParser;
|
||||
}
|
||||
|
||||
void RecognizeSystem::SetSocket(QTcpSocket *socket)
|
||||
@@ -34,7 +35,6 @@ void RecognizeSystem::Recognize()
|
||||
|
||||
while(socket->bytesAvailable())
|
||||
{
|
||||
|
||||
if(packetType == PacketType::TYPE_NONE){ //определение первичного пакета
|
||||
|
||||
stream.startTransaction();
|
||||
@@ -148,7 +148,11 @@ void RecognizeSystem::Recognize()
|
||||
stream >> tmpBlock;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
//qDebug() << Tools::GetTime() << "CLIENT: tmpBlock - FAIL";
|
||||
|
||||
if(socket->state() == QAbstractSocket::UnconnectedState){
|
||||
emit SockedDisabled();
|
||||
return;
|
||||
}
|
||||
if(socket->waitForReadyRead(TCP_READ_TIMEOUT)){
|
||||
continue;
|
||||
}
|
||||
@@ -157,7 +161,7 @@ void RecognizeSystem::Recognize()
|
||||
}
|
||||
|
||||
quint64 toFile = file.write(tmpBlock);
|
||||
emit onSendDebugLog(Tools::GetTime() + "CLIENT: toFile :" + toFile);
|
||||
emit onSendDebugLog(Tools::GetTime() + "CLIENT: toFile :" + toFile);
|
||||
|
||||
sizeReceiveData += toFile;
|
||||
countSend++;
|
||||
@@ -226,7 +230,7 @@ void RecognizeSystem::Recognize()
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
if(packetType == PacketType::TYPE_NEEDUPDATE){
|
||||
if(packetType == PacketType::TYPE_NEEDUPDATE){ //нужно обновление
|
||||
|
||||
bool flag;
|
||||
|
||||
@@ -237,7 +241,52 @@ void RecognizeSystem::Recognize()
|
||||
emit onNeedUpdate(flag);
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
if(packetType == PacketType::TYPE_XMLANSWER){ //ответы формата XML
|
||||
QByteArray array;
|
||||
stream.startTransaction();
|
||||
stream >> array;
|
||||
|
||||
XMLParser(array);
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void RecognizeSystem::XMLParser(QByteArray array)
|
||||
{
|
||||
QXmlStreamReader xmlReader(array);
|
||||
|
||||
xmlReader.readNext();
|
||||
|
||||
while(!xmlReader.atEnd())
|
||||
{
|
||||
if(!xmlReader.isStartElement()) {
|
||||
xmlReader.readNext();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(xmlReader.name() == "ServerNotify")
|
||||
{
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
|
||||
if(name == "Code"){
|
||||
if (value == "END"){
|
||||
|
||||
emit SockedDisabled();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xmlReader.readNext();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user