mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 04:18:12 +02:00
Clean up AssetRequest
This commit is contained in:
parent
15854c6715
commit
92dbe9997c
2 changed files with 2 additions and 28 deletions
|
@ -27,7 +27,6 @@ AssetRequest::AssetRequest(QObject* parent, QString hash) :
|
||||||
void AssetRequest::start() {
|
void AssetRequest::start() {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "start", Qt::AutoConnection);
|
QMetaObject::invokeMethod(this, "start", Qt::AutoConnection);
|
||||||
//(&AssetRequest::start)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ void AssetRequest::start() {
|
||||||
assetClient->getAssetInfo(_hash, [this](bool success, AssetInfo info) {
|
assetClient->getAssetInfo(_hash, [this](bool success, AssetInfo info) {
|
||||||
_info = info;
|
_info = info;
|
||||||
_data.resize(info.size);
|
_data.resize(info.size);
|
||||||
const DataOffset CHUNK_SIZE = 1024;
|
const DataOffset CHUNK_SIZE = 1024000000;
|
||||||
|
|
||||||
qDebug() << "Got size of " << _hash << " : " << info.size << " bytes";
|
qDebug() << "Got size of " << _hash << " : " << info.size << " bytes";
|
||||||
|
|
||||||
|
@ -72,7 +71,3 @@ void AssetRequest::start() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QByteArray& AssetRequest::getData() {
|
|
||||||
return _data;
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,18 +19,6 @@
|
||||||
|
|
||||||
#include "AssetUtils.h"
|
#include "AssetUtils.h"
|
||||||
|
|
||||||
// You should be able to get an asset from any thread, and handle the responses in a safe way
|
|
||||||
// on your own thread. Everything should happen on AssetClient's thread, the caller should
|
|
||||||
// receive events by connecting to signals on an object that lives on AssetClient's threads.
|
|
||||||
|
|
||||||
// Receives parts of an asset and puts them together
|
|
||||||
// Emits signals:
|
|
||||||
// Progress
|
|
||||||
// Completion, success or error
|
|
||||||
// On finished, the AssetClient is effectively immutable and can be read from
|
|
||||||
// any thread safely
|
|
||||||
//
|
|
||||||
// Will often make multiple requests to the AssetClient to get data
|
|
||||||
class AssetRequest : public QObject {
|
class AssetRequest : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -51,16 +39,8 @@ public:
|
||||||
AssetRequest(QObject* parent, QString hash);
|
AssetRequest(QObject* parent, QString hash);
|
||||||
|
|
||||||
Q_INVOKABLE void start();
|
Q_INVOKABLE void start();
|
||||||
//AssetRequest* requestAsset(QString hash);
|
|
||||||
// Create AssetRequest
|
|
||||||
// Start request for hash
|
|
||||||
// Store messageID -> AssetRequest
|
|
||||||
// When complete:
|
|
||||||
// Update AssetRequest
|
|
||||||
// AssetRequest emits signal
|
|
||||||
|
|
||||||
void receiveData(DataOffset start, DataOffset end, QByteArray data);
|
const QByteArray& getData() { return _data; }
|
||||||
const QByteArray& getData();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished(AssetRequest*);
|
void finished(AssetRequest*);
|
||||||
|
@ -74,7 +54,6 @@ private:
|
||||||
QString _hash;
|
QString _hash;
|
||||||
QByteArray _data;
|
QByteArray _data;
|
||||||
int _numPendingRequests { 0 };
|
int _numPendingRequests { 0 };
|
||||||
// Timeout
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue