ref: change send command

This commit is contained in:
semenov
2025-01-17 10:49:27 +03:00
parent e1c3fcae36
commit 7b8f920cdc
47 changed files with 7765 additions and 600 deletions

View File

@@ -98,6 +98,46 @@ void SendSystem::sendFolderBlock(QString path)
socket->waitForReadyRead(100);
}
void SendSystem::sendFileBlockWithVersion(QString localPath,QString serverPath)
{
QDataStream stream(socket);
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
//QString fullPath = Tools::createLocalPath(localPath);
quint64 fileSize = 0;
int countSend = 0;
QFile file(localPath); //Открываем файл для чтения
QFileInfo fileInfo(file);
fileSize = fileInfo.size();
stream << PacketType::TYPE_FILE; //Отправляем тип блока
stream << serverPath << fileSize;
socket->waitForReadyRead(20);
//socket->waitForBytesWritten();
if(file.open(QFile::ReadOnly)){
while(!file.atEnd()){
QByteArray data = file.read(1025*250);
stream << data;
socket->waitForBytesWritten();
countSend++;
}
qDebug() << Tools::getTime() << "count end Final: " << countSend;
}
file.close();
emit sigSend();
//qDebug() << "Transaction after send file: " << socket->isTransactionStarted();
countSend = 0;
//socket->waitForBytesWritten();
socket->waitForReadyRead(20);
}
void SendSystem::sendQTConnect()
{
QString value = QString::number(PacketType::TYPE_QT);
@@ -158,6 +198,37 @@ void SendSystem::sendCopyVersion(QString streamingVersion)
stream << streamingVersion;
}
void SendSystem::sendPacketType(PacketType packetType)
{
QDataStream stream(socket);
QByteArray data;
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
stream << packetType;
}
void SendSystem::sendCheckHash()
{
QDataStream stream(socket);
QByteArray data;
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
sendFileBlock(staticDataFolderName + hashFilename);
socket->waitForReadyRead(2000);
stream << PacketType::TYPE_CHECK_VERSION;
//socket->waitForReadyRead(1000);
// else if(command == "update")
// {
// qDebug() << ("Update started");
// stream << PacketType::TYPE_COMMAND;
// stream << command;
// socket->waitForReadyRead(1000);
// }
}
SendSystem::~SendSystem()
{