mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 00:59:56 +02:00
use the exact payload size where possible
This commit is contained in:
parent
e7e1f5fe5c
commit
2849d80274
1 changed files with 11 additions and 5 deletions
|
@ -57,7 +57,8 @@ AssetRequest* AssetClient::createRequest(const QString& hash, const QString& ext
|
|||
SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
|
||||
|
||||
if (!assetServer) {
|
||||
qDebug().nospace() << "Could not request " << hash << "." << extension << " since you are not currently connected to an asset-server.";
|
||||
qDebug().nospace() << "Could not request " << hash << "." << extension
|
||||
<< " since you are not currently connected to an asset-server.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -96,10 +97,13 @@ bool AssetClient::getAsset(const QString& hash, const QString& extension, DataOf
|
|||
SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
|
||||
|
||||
if (assetServer) {
|
||||
auto packet = NLPacket::create(PacketType::AssetGet, -1, true);
|
||||
|
||||
|
||||
auto messageID = ++_currentID;
|
||||
|
||||
auto payloadSize = sizeof(messageID) + SHA256_HASH_LENGTH + sizeof(uint8_t) + extension.length()
|
||||
+ sizeof(start) + sizeof(end);
|
||||
auto packet = NLPacket::create(PacketType::AssetGet, payloadSize, true);
|
||||
|
||||
qDebug() << "Requesting data from" << start << "to" << end << "of" << hash << "from asset-server.";
|
||||
|
||||
packet->writePrimitive(messageID);
|
||||
|
@ -127,9 +131,11 @@ bool AssetClient::getAssetInfo(const QString& hash, const QString& extension, Ge
|
|||
SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
|
||||
|
||||
if (assetServer) {
|
||||
auto packet = NLPacket::create(PacketType::AssetGetInfo, -1, true);
|
||||
|
||||
auto messageID = ++_currentID;
|
||||
|
||||
auto payloadSize = sizeof(messageID) + SHA256_HASH_LENGTH + sizeof(uint8_t) + extension.length();
|
||||
auto packet = NLPacket::create(PacketType::AssetGetInfo, payloadSize, true);
|
||||
|
||||
packet->writePrimitive(messageID);
|
||||
packet->write(QByteArray::fromHex(hash.toLatin1()));
|
||||
packet->writePrimitive(uint8_t(extension.length()));
|
||||
|
|
Loading…
Reference in a new issue