OpenMetaverse.AssetManager.RequestAsset C# (CSharp) Method

RequestAsset() public method

Request an asset download
public RequestAsset ( UUID assetID, AssetType type, bool priority, AssetReceivedCallback callback ) : void
assetID UUID Asset UUID
type AssetType Asset type, must be correct for the transfer to succeed
priority bool Whether to give this transfer an elevated priority
callback AssetReceivedCallback The callback to fire when the simulator responds with the asset data
return void
        public void RequestAsset(UUID assetID, AssetType type, bool priority, AssetReceivedCallback callback)
        {
            RequestAsset(assetID, type, priority, SourceType.Asset, UUID.Random(), callback);
        }

Same methods

AssetManager::RequestAsset ( UUID assetID, AssetType type, bool priority, SourceType sourceType, AssetReceivedCallback callback ) : void
AssetManager::RequestAsset ( UUID assetID, AssetType type, bool priority, SourceType sourceType, UUID transactionID, AssetReceivedCallback callback ) : void

Usage Example

        public static void SaveSimAssets(AssetManager assetManager, AssetType assetType, UUID assetID, UUID itemID, UUID primID, string assetsPath)
        {
            int count = 0;

            AutoResetEvent AllPropertiesReceived = new AutoResetEvent(false);
            assetManager.RequestAsset(assetID, itemID, primID, assetType, false, SourceType.SimInventoryItem, UUID.Random(), (transfer, asset) =>
            {
                string extension = string.Empty;

                if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(assetType))
                    extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[assetType];

                if (asset == null)
                {
                    AllPropertiesReceived.Set();
                    return;
                }
                File.WriteAllBytes(Path.Combine(assetsPath, assetID.ToString() + extension), asset.AssetData);
                ++count;
                AllPropertiesReceived.Set();
            });
            AllPropertiesReceived.WaitOne(5000);

            Logger.Log("Copied " + count + " textures to the asset archive folder", Helpers.LogLevel.Info);
        }
All Usage Examples Of OpenMetaverse.AssetManager::RequestAsset