mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 01:36:26 +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);
|
SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
|
||||||
|
|
||||||
if (!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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,10 +97,13 @@ bool AssetClient::getAsset(const QString& hash, const QString& extension, DataOf
|
||||||
SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
|
SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
|
||||||
|
|
||||||
if (assetServer) {
|
if (assetServer) {
|
||||||
auto packet = NLPacket::create(PacketType::AssetGet, -1, true);
|
|
||||||
|
|
||||||
auto messageID = ++_currentID;
|
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.";
|
qDebug() << "Requesting data from" << start << "to" << end << "of" << hash << "from asset-server.";
|
||||||
|
|
||||||
packet->writePrimitive(messageID);
|
packet->writePrimitive(messageID);
|
||||||
|
@ -127,9 +131,11 @@ bool AssetClient::getAssetInfo(const QString& hash, const QString& extension, Ge
|
||||||
SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
|
SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
|
||||||
|
|
||||||
if (assetServer) {
|
if (assetServer) {
|
||||||
auto packet = NLPacket::create(PacketType::AssetGetInfo, -1, true);
|
|
||||||
|
|
||||||
auto messageID = ++_currentID;
|
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->writePrimitive(messageID);
|
||||||
packet->write(QByteArray::fromHex(hash.toLatin1()));
|
packet->write(QByteArray::fromHex(hash.toLatin1()));
|
||||||
packet->writePrimitive(uint8_t(extension.length()));
|
packet->writePrimitive(uint8_t(extension.length()));
|
||||||
|
|
Loading…
Reference in a new issue