CHttpPackageProvider implements the IStreamedPackageProvider interface to download game assets on demand from an HTTP CDN. Files are downloaded as LZMA-compressed archives, decompressed, verified by SHA1 hash, and cached locally for subsequent access.
This is the mechanism used by the Ryzom client to stream assets that are not included in the initial install, avoiding large upfront downloads.
Header: nel/web/http_package_provider.h
#include <nel/web/http_package_provider.h>
#include <nel/misc/streamed_package_manager.h>
// Create and configure the provider
NLWEB::CHttpPackageProvider *provider = new NLWEB::CHttpPackageProvider();
provider->Path = "stream/"; // local cache directory
provider->Hosts.push_back("http://cdn.example.com/assets/stream/");
// Register with the streamed package manager
NLMISC::CStreamedPackageManager &spm = NLMISC::CStreamedPackageManager::getInstance();
spm.Provider = provider;
// Assets are now downloaded on demand when CPath resolves a streamed file
| Member | Type | Description |
|---|---|---|
Path |
std::string |
Local directory for caching downloaded files. Files are stored in a hash-based subdirectory tree. |
Hosts |
std::vector<std::string> |
List of HTTP CDN base URLs to download from. The provider tries each host in order. |
When getFile is called with a SHA1 hash:
Path + hash_path, return it immediately.host + hash_path + ".lzma" from each configured CDN host until one succeeds. The download goes to a temporary .download.RANDOM file..extract.RANDOM file.If the download fails, the provider retries with a 1-second delay between attempts. The operation is blocking — it runs on the async file loading thread, not the main thread.
File paths within the cache use the format from CStreamedPackage::makePath(hash), which creates a directory tree based on the hash bytes to avoid having too many files in a single directory.
NLMISC::EDiskFullError.The Ryzom client configures the provider from client.cfg:
StreamedPackagePath = "stream/";
StreamedPackageHosts = {
"http://cdn.ryzom.dev/open/stream/"
};
The provider is created during client initialization (initStreamedPackageManager in init.cpp) and destroyed during shutdown (release.cpp).