ref: init package

This commit is contained in:
semenov
2025-06-26 17:59:24 +03:00
parent ef17ee4ab8
commit ce78420a07
2 changed files with 23 additions and 8 deletions

View File

@@ -96,8 +96,14 @@ void SendSystem::sendFolderBlock(QString path)
void SendSystem::sendQTConnect() void SendSystem::sendQTConnect()
{ {
QString value = QString::number(PacketType::TYPE_QT); QByteArray container;
socket->write(value.toUtf8()); int numPackage = (int)PacketType::TYPE_QT;
container.append(numPackage & 0x000000ff);
container.append((numPackage >> 8) & 0x000000ff);
container.append((numPackage >> 16) & 0x000000ff);
container.append((numPackage >> 24) & 0x000000ff);
socket->write(container);
socket->waitForBytesWritten(); socket->waitForBytesWritten();
} }

View File

@@ -51,10 +51,15 @@ void RecognizeSystem::recognize()
if(!isPackageTypeInited) //первичная инициализация для типа клиента if(!isPackageTypeInited) //первичная инициализация для типа клиента
{ {
char *read = new char[0]; // char *read = new char[0];
stream.readRawData(read,1); // stream.readRawData(read,1);
packetType = static_cast<PacketType>(QString(read[0]).toInt()); // packetType = static_cast<PacketType>(QString(read[0]).toInt());
char *read = new char[4];
stream.readRawData(read,4);
int numPackage = *((int*)read);
packetType = static_cast<PacketType>(numPackage);
packetTypeInit(packetType,client); packetTypeInit(packetType,client);
if(!stream.commitTransaction()) continue; if(!stream.commitTransaction()) continue;
@@ -63,9 +68,13 @@ void RecognizeSystem::recognize()
if(client->getIsUnity()) if(client->getIsUnity())
{ {
char *read = new char[0]; char *read = new char[4];
stream.readRawData(read,1); stream.readRawData(read,4);
packetType = static_cast<PacketType>(QString(read[0]).toInt()); int numPackage = *((int*)read);
packetType = static_cast<PacketType>(numPackage);
socket->peek(read,4);
//data = socket->readAll();
if(!stream.commitTransaction()) continue; if(!stream.commitTransaction()) continue;
continue; continue;