mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
bugfix: sent packetType
This commit is contained in:
@@ -17,6 +17,7 @@ enum PacketType
|
|||||||
TYPE_UPDATE = 12,
|
TYPE_UPDATE = 12,
|
||||||
TYPE_CHECK_VERSION = 13,
|
TYPE_CHECK_VERSION = 13,
|
||||||
TYPE_FILESIZE = 20,
|
TYPE_FILESIZE = 20,
|
||||||
|
TYPE_BIGXML = 21,
|
||||||
|
|
||||||
TYPE_XMLANSWER_MESSAGE_FOR_GUI = 90,
|
TYPE_XMLANSWER_MESSAGE_FOR_GUI = 90,
|
||||||
|
|
||||||
|
|||||||
@@ -475,12 +475,12 @@ void ProcessingSystem::sendTaskListToUnity(ClientHandler *client)
|
|||||||
//AMM
|
//AMM
|
||||||
QList<TaskAmmFim> listTasksAMM = providerDBLMS->GetListTasksAMMofTrainee(id_trainee);
|
QList<TaskAmmFim> listTasksAMM = providerDBLMS->GetListTasksAMMofTrainee(id_trainee);
|
||||||
QByteArray arrayAnswerTasksAMM = dataParser->DbAnswer()->listTasksAMMofTrainee(true, &listTasksAMM, id_trainee);
|
QByteArray arrayAnswerTasksAMM = dataParser->DbAnswer()->listTasksAMMofTrainee(true, &listTasksAMM, id_trainee);
|
||||||
client->sendXmlAnswer(arrayAnswerTasksAMM, PacketType::TYPE_XMLANSWER_QUERY_TASKS_AMM_OF_TRAINEE);
|
client->sendFileBlockByteArray(arrayAnswerTasksAMM, PacketType::TYPE_XMLANSWER_QUERY_TASKS_AMM_OF_TRAINEE);
|
||||||
|
|
||||||
//FIM
|
//FIM
|
||||||
QList<TaskAmmFim> listTasksFIM = providerDBLMS->GetListTasksFIMofTrainee(id_trainee);
|
QList<TaskAmmFim> listTasksFIM = providerDBLMS->GetListTasksFIMofTrainee(id_trainee);
|
||||||
QByteArray arrayAnswerFIM = dataParser->DbAnswer()->listTasksFIMofTrainee(true, &listTasksFIM, id_trainee);
|
QByteArray arrayAnswerFIM = dataParser->DbAnswer()->listTasksFIMofTrainee(true, &listTasksFIM, id_trainee);
|
||||||
client->sendXmlAnswer(arrayAnswerFIM, PacketType::TYPE_XMLANSWER_QUERY_TASKS_FIM_OF_TRAINEE);
|
client->sendFileBlockByteArray(arrayAnswerFIM, PacketType::TYPE_XMLANSWER_QUERY_TASKS_FIM_OF_TRAINEE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,6 @@ void RecognizeSystem::recognize()
|
|||||||
packetType = static_cast<PacketType>(numPackage);
|
packetType = static_cast<PacketType>(numPackage);
|
||||||
|
|
||||||
socket->peek(read,4);
|
socket->peek(read,4);
|
||||||
//data = socket->readAll();
|
|
||||||
|
|
||||||
if(!stream.commitTransaction()) continue;
|
if(!stream.commitTransaction()) continue;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -135,6 +133,59 @@ void RecognizeSystem::recognize()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(packetType == PacketType::TYPE_BIGXML)
|
||||||
|
{
|
||||||
|
if (clientHandler->getClient()->getIsUnity())
|
||||||
|
{
|
||||||
|
char *readBuffer = new char[4];
|
||||||
|
socket->read(readBuffer,4);
|
||||||
|
fileSize = *((int*)readBuffer);
|
||||||
|
|
||||||
|
stream.commitTransaction();
|
||||||
|
//if(!) continue;
|
||||||
|
//ПОЛУЧЕНИЕ САМОГО ФАЙЛА
|
||||||
|
qDebug() << (Tools::getTime() + "AfterRead size and path BytesAvailable: " + socket->bytesAvailable());
|
||||||
|
|
||||||
|
qint64 readSize = 65535;
|
||||||
|
forever
|
||||||
|
{
|
||||||
|
|
||||||
|
if(fileSize < readSize)
|
||||||
|
{
|
||||||
|
readSize = fileSize;
|
||||||
|
qDebug() << "LastPackage: " << readSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
socket->waitForReadyRead(20);
|
||||||
|
tmpBlock = socket->read(readSize);
|
||||||
|
|
||||||
|
data.append(tmpBlock);
|
||||||
|
|
||||||
|
fileSize -= readSize;
|
||||||
|
sizeReceiveData += readSize;
|
||||||
|
countSend++;
|
||||||
|
|
||||||
|
tmpBlock.clear();
|
||||||
|
|
||||||
|
if(fileSize == 0) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << (Tools::getTime() + "File loaded");
|
||||||
|
|
||||||
|
//ОЧИСТКА ПОСЛЕ ПЕРЕДАЧИ
|
||||||
|
fileSize = 0;
|
||||||
|
tmpBlock.clear();
|
||||||
|
sizeReceiveData = 0;
|
||||||
|
countSend = 0;
|
||||||
|
|
||||||
|
emit sigXmlParser(clientHandler,data);
|
||||||
|
|
||||||
|
packetType = PacketType::TYPE_NONE;
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(packetType == PacketType::TYPE_FOLDER) //создание папок
|
if(packetType == PacketType::TYPE_FOLDER) //создание папок
|
||||||
{
|
{
|
||||||
if(client->getIsUnity())
|
if(client->getIsUnity())
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ void SendSystem::sendFileBlockByteArray(QByteArray array, PacketType packetType)
|
|||||||
{
|
{
|
||||||
qDebug() << "sendFileBlockByteArray thread: " << QThread::currentThreadId();
|
qDebug() << "sendFileBlockByteArray thread: " << QThread::currentThreadId();
|
||||||
|
|
||||||
|
if(!client->getIsUnity())
|
||||||
|
{
|
||||||
QDataStream stream(socket);
|
QDataStream stream(socket);
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
|
||||||
@@ -103,11 +105,21 @@ void SendSystem::sendFileBlockByteArray(QByteArray array, PacketType packetType)
|
|||||||
}
|
}
|
||||||
|
|
||||||
stream << packetType; //Отправляем тип блока
|
stream << packetType; //Отправляем тип блока
|
||||||
|
|
||||||
stream << fileSize;
|
stream << fileSize;
|
||||||
|
|
||||||
stream << array;
|
stream << array;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sendPacketType(packetType);
|
||||||
|
QByteArray message;
|
||||||
|
int size = array.length();
|
||||||
|
message.append(reinterpret_cast<char*>(&size), sizeof(int));
|
||||||
|
socket->write(message);
|
||||||
|
socket->write(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void SendSystem::sendVersion()
|
void SendSystem::sendVersion()
|
||||||
{
|
{
|
||||||
@@ -187,11 +199,22 @@ void SendSystem::sendDeleteBlock(QString path)
|
|||||||
|
|
||||||
void SendSystem::sendPacketType(PacketType packetType)
|
void SendSystem::sendPacketType(PacketType packetType)
|
||||||
{
|
{
|
||||||
|
if(!client->getIsUnity())
|
||||||
|
{
|
||||||
|
|
||||||
QDataStream stream(socket);
|
QDataStream stream(socket);
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
stream << packetType;
|
stream << packetType;
|
||||||
socket->waitForReadyRead(100);
|
socket->waitForReadyRead(100);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QByteArray message;
|
||||||
|
int type = (int)packetType;
|
||||||
|
message.append(reinterpret_cast<char*>(&type), sizeof(int));
|
||||||
|
socket->write(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SendSystem::sendHello()
|
void SendSystem::sendHello()
|
||||||
{
|
{
|
||||||
@@ -219,27 +242,13 @@ void SendSystem::sendXmlAnswer(QByteArray array, PacketType packetType)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//QByteArray buffer(512,0);
|
sendPacketType(packetType);
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
message.append("size=");
|
|
||||||
int size = array.length();
|
int size = array.length();
|
||||||
message.append(reinterpret_cast<char*>(&size), sizeof(int));
|
message.append(reinterpret_cast<char*>(&size), sizeof(int));
|
||||||
|
|
||||||
qDebug() << "Message size " << message.length();
|
|
||||||
qDebug() << array.length();
|
|
||||||
socket->write(message);
|
socket->write(message);
|
||||||
|
|
||||||
if(array.length() <= 512)
|
|
||||||
{
|
|
||||||
// QByteArray buffer2(512,0);
|
|
||||||
// memcpy(buffer2.data(),array.data(),array.length());
|
|
||||||
socket->write(array);
|
socket->write(array);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
socket->write(array);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendSystem::sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount)
|
void SendSystem::sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount)
|
||||||
|
|||||||
Reference in New Issue
Block a user