diff --git a/OpenMetaverse/AgentManager.cs b/OpenMetaverse/AgentManager.cs
index dbebba8c..da1fa05a 100644
--- a/OpenMetaverse/AgentManager.cs
+++ b/OpenMetaverse/AgentManager.cs
@@ -2168,20 +2168,6 @@ namespace OpenMetaverse
{
// First fetch the guesture
AssetGesture gesture = null;
- AutoResetEvent gotAsset = new AutoResetEvent(false);
-
- AssetManager.AssetReceivedCallback callback =
- delegate(AssetDownload transfer, Asset asset)
- {
- if (transfer.AssetID != gestureID) return;
-
- if (transfer.Success)
- {
- gesture = (AssetGesture)asset;
- }
-
- gotAsset.Set();
- };
if (gestureCache.ContainsKey(gestureID))
{
@@ -2189,10 +2175,21 @@ namespace OpenMetaverse
}
else
{
- Client.Assets.OnAssetReceived += callback;
- Client.Assets.RequestAsset(gestureID, AssetType.Gesture, true);
+ AutoResetEvent gotAsset = new AutoResetEvent(false);
+
+ Client.Assets.RequestAsset(gestureID, AssetType.Gesture, true,
+ delegate(AssetDownload transfer, Asset asset)
+ {
+ if (transfer.Success)
+ {
+ gesture = (AssetGesture)asset;
+ }
+
+ gotAsset.Set();
+ }
+ );
+
gotAsset.WaitOne(30 * 1000, false);
- Client.Assets.OnAssetReceived -= callback;
if (gesture != null && gesture.Decode())
{
diff --git a/OpenMetaverse/AppearanceManager.cs b/OpenMetaverse/AppearanceManager.cs
index 727f119e..f6d4a161 100644
--- a/OpenMetaverse/AppearanceManager.cs
+++ b/OpenMetaverse/AppearanceManager.cs
@@ -647,21 +647,13 @@ namespace OpenMetaverse
AgentTextures[i] = UUID.Zero;
}
- // Register an asset download callback to get wearable data
- AssetManager.AssetReceivedCallback assetCallback = new AssetManager.AssetReceivedCallback(Assets_OnAssetReceived);
-
AssetManager.AssetUploadedCallback uploadCallback = new AssetManager.AssetUploadedCallback(Assets_OnAssetUploaded);
- Assets.OnAssetReceived += assetCallback;
-
Assets.OnAssetUploaded += uploadCallback;
// Download assets for what we are wearing and fill in AgentTextures
DownloadWearableAssets();
WearablesDownloadedEvent.WaitOne();
- // Unregister the asset download callback
- Assets.OnAssetReceived -= assetCallback;
-
// Check if anything needs to be rebaked
if (bake) RequestCachedBakes();
@@ -1099,7 +1091,7 @@ namespace OpenMetaverse
if (AssetDownloads.Count > 0)
{
PendingAssetDownload pad = AssetDownloads.Dequeue();
- Assets.RequestAsset(pad.Id, pad.Type, true);
+ Assets.RequestAsset(pad.Id, pad.Type, true, Assets_OnAssetReceived);
}
}
@@ -1428,7 +1420,7 @@ namespace OpenMetaverse
{
// Dowload the next wearable in line
PendingAssetDownload pad = AssetDownloads.Dequeue();
- Assets.RequestAsset(pad.Id, pad.Type, true);
+ Assets.RequestAsset(pad.Id, pad.Type, true, Assets_OnAssetReceived);
}
else
{
diff --git a/OpenMetaverse/TextureCache.cs b/OpenMetaverse/AssetCache.cs
similarity index 81%
rename from OpenMetaverse/TextureCache.cs
rename to OpenMetaverse/AssetCache.cs
index 1f8bcb5f..65e55560 100644
--- a/OpenMetaverse/TextureCache.cs
+++ b/OpenMetaverse/AssetCache.cs
@@ -32,14 +32,14 @@ using System.Threading;
namespace OpenMetaverse
{
///
- /// Class that handles the local image cache
+ /// Class that handles the local asset cache
///
- public class TextureCache
+ public class AssetCache
{
- // User can plug in a routine to compute the texture cache location
- public delegate string ComputeTextureCacheFilenameDelegate(string cacheDir, UUID textureID);
+ // User can plug in a routine to compute the asset cache location
+ public delegate string ComputeAssetCacheFilenameDelegate(string cacheDir, UUID assetID);
- public ComputeTextureCacheFilenameDelegate ComputeTextureCacheFilename = null;
+ public ComputeAssetCacheFilenameDelegate ComputeAssetCacheFilename = null;
private GridClient Client;
private Thread cleanerThread;
@@ -86,7 +86,7 @@ namespace OpenMetaverse
/// Default constructor
///
/// A reference to the GridClient object
- public TextureCache(GridClient client)
+ public AssetCache(GridClient client)
{
Client = client;
Client.Network.OnConnected += new NetworkManager.ConnectedCallback(Network_OnConnected);
@@ -133,11 +133,11 @@ namespace OpenMetaverse
}
///
- /// Return bytes read from the local image cache, null if it does not exist
+ /// Return bytes read from the local asset cache, null if it does not exist
///
- /// UUID of the image we want to get
- /// Raw bytes of the image, or null on failure
- public byte[] GetCachedImageBytes(UUID imageID)
+ /// UUID of the asset we want to get
+ /// Raw bytes of the asset, or null on failure
+ public byte[] GetCachedAssetBytes(UUID assetID)
{
if (!Operational())
{
@@ -145,13 +145,13 @@ namespace OpenMetaverse
}
try
{
- Logger.DebugLog("Reading " + FileName(imageID) + " from texture cache.");
- byte[] data = File.ReadAllBytes(FileName(imageID));
+ Logger.DebugLog("Reading " + FileName(assetID) + " from asset cache.");
+ byte[] data = File.ReadAllBytes(FileName(assetID));
return data;
}
catch (Exception ex)
{
- Logger.Log("Failed reading image from cache (" + ex.Message + ")", Helpers.LogLevel.Warning, Client);
+ Logger.Log("Failed reading asset from cache (" + ex.Message + ")", Helpers.LogLevel.Warning, Client);
return null;
}
}
@@ -167,7 +167,7 @@ namespace OpenMetaverse
if (!Operational())
return null;
- byte[] imageData = GetCachedImageBytes(imageID);
+ byte[] imageData = GetCachedAssetBytes(imageID);
if (imageData == null)
return null;
ImageDownload transfer = new ImageDownload();
@@ -182,25 +182,25 @@ namespace OpenMetaverse
}
///
- /// Constructs a file name of the cached image
+ /// Constructs a file name of the cached asset
///
- /// UUID of the image
- /// String with the file name of the cahced image
- private string FileName(UUID imageID)
+ /// UUID of the asset
+ /// String with the file name of the cahced asset
+ private string FileName(UUID assetID)
{
- if (ComputeTextureCacheFilename != null) {
- return ComputeTextureCacheFilename(Client.Settings.TEXTURE_CACHE_DIR, imageID);
+ if (ComputeAssetCacheFilename != null) {
+ return ComputeAssetCacheFilename(Client.Settings.TEXTURE_CACHE_DIR, assetID);
}
- return Client.Settings.TEXTURE_CACHE_DIR + Path.DirectorySeparatorChar + imageID.ToString();
+ return Client.Settings.TEXTURE_CACHE_DIR + Path.DirectorySeparatorChar + assetID.ToString();
}
///
- /// Saves an image to the local cache
+ /// Saves an asset to the local cache
///
- /// UUID of the image
- /// Raw bytes the image consists of
+ /// UUID of the asset
+ /// Raw bytes the asset consists of
/// Weather the operation was successfull
- public bool SaveImageToCache(UUID imageID, byte[] imageData)
+ public bool SaveAssetToCache(UUID assetID, byte[] assetData)
{
if (!Operational())
{
@@ -209,18 +209,18 @@ namespace OpenMetaverse
try
{
- Logger.DebugLog("Saving " + FileName(imageID) + " to texture cache.", Client);
+ Logger.DebugLog("Saving " + FileName(assetID) + " to asset cache.", Client);
if (!Directory.Exists(Client.Settings.TEXTURE_CACHE_DIR))
{
Directory.CreateDirectory(Client.Settings.TEXTURE_CACHE_DIR);
}
- File.WriteAllBytes(FileName(imageID), imageData);
+ File.WriteAllBytes(FileName(assetID), assetData);
}
catch (Exception ex)
{
- Logger.Log("Failed saving image to cache (" + ex.Message + ")", Helpers.LogLevel.Warning, Client);
+ Logger.Log("Failed saving asset to cache (" + ex.Message + ")", Helpers.LogLevel.Warning, Client);
return false;
}
@@ -230,16 +230,16 @@ namespace OpenMetaverse
///
/// Get the file name of the asset stored with gived UUID
///
- /// UUID of the image
+ /// UUID of the asset
/// Null if we don't have that UUID cached on disk, file name if found in the cache folder
- public string ImageFileName(UUID imageID)
+ public string AssetFileName(UUID assetID)
{
if (!Operational())
{
return null;
}
- string fileName = FileName(imageID);
+ string fileName = FileName(assetID);
if (File.Exists(fileName))
return fileName;
@@ -248,16 +248,16 @@ namespace OpenMetaverse
}
///
- /// Checks if the image exists in the local cache
+ /// Checks if the asset exists in the local cache
///
- /// UUID of the image
- /// True is the image is stored in the cache, otherwise false
- public bool HasImage(UUID imageID)
+ /// UUID of the asset
+ /// True is the asset is stored in the cache, otherwise false
+ public bool HasAsset(UUID assetID)
{
if (!Operational())
return false;
else
- return File.Exists(FileName(imageID));
+ return File.Exists(FileName(assetID));
}
///
diff --git a/OpenMetaverse/AssetManager.cs b/OpenMetaverse/AssetManager.cs
index b3c3dbf5..26939d8d 100644
--- a/OpenMetaverse/AssetManager.cs
+++ b/OpenMetaverse/AssetManager.cs
@@ -192,7 +192,7 @@ namespace OpenMetaverse
public StatusCode Status;
public float Priority;
public Simulator Simulator;
-
+ public AssetManager.AssetReceivedCallback Callback;
internal AutoResetEvent HeaderReceivedEvent = new AutoResetEvent(false);
public AssetDownload()
@@ -329,8 +329,6 @@ namespace OpenMetaverse
#region Events
- ///
- public event AssetReceivedCallback OnAssetReceived;
///
public event XferReceivedCallback OnXferReceived;
///
@@ -344,7 +342,7 @@ namespace OpenMetaverse
#endregion Events
/// Texture download cache
- public TextureCache Cache;
+ public AssetCache Cache;
private TexturePipeline Texture;
@@ -363,7 +361,7 @@ namespace OpenMetaverse
public AssetManager(GridClient client)
{
Client = client;
- Cache = new TextureCache(client);
+ Cache = new AssetCache(client);
Texture = new TexturePipeline(client);
// Transfer packets for downloading large assets
@@ -390,10 +388,9 @@ namespace OpenMetaverse
/// Asset UUID
/// Asset type, must be correct for the transfer to succeed
/// Whether to give this transfer an elevated priority
- /// The transaction ID generated for this transfer
- public UUID RequestAsset(UUID assetID, AssetType type, bool priority)
+ public void RequestAsset(UUID assetID, AssetType type, bool priority, AssetReceivedCallback callback)
{
- return RequestAsset(assetID, type, priority, SourceType.Asset);
+ RequestAsset(assetID, type, priority, SourceType.Asset, callback);
}
///
@@ -403,8 +400,7 @@ namespace OpenMetaverse
/// Asset type, must be correct for the transfer to succeed
/// Whether to give this transfer an elevated priority
/// Source location of the requested asset
- /// The transaction ID generated for this transfer
- public UUID RequestAsset(UUID assetID, AssetType type, bool priority, SourceType sourceType)
+ public void RequestAsset(UUID assetID, AssetType type, bool priority, SourceType sourceType, AssetReceivedCallback callback)
{
AssetDownload transfer = new AssetDownload();
transfer.ID = UUID.Random();
@@ -414,6 +410,25 @@ namespace OpenMetaverse
transfer.Channel = ChannelType.Asset;
transfer.Source = sourceType;
transfer.Simulator = Client.Network.CurrentSim;
+ transfer.Callback = callback;
+
+ // Check asset cache first
+ if (callback != null && Cache.HasAsset(assetID))
+ {
+ byte[] data = Cache.GetCachedAssetBytes(assetID);
+ transfer.AssetData = data;
+ transfer.Success = true;
+ transfer.Status = StatusCode.OK;
+
+ Asset asset = CreateAssetWrapper(type);
+ asset.AssetData = data;
+ asset.AssetID = assetID;
+
+ try { callback(transfer, asset); }
+ catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
+
+ return;
+ }
// Add this transfer to the dictionary
lock (Transfers) Transfers[transfer.ID] = transfer;
@@ -431,7 +446,6 @@ namespace OpenMetaverse
request.TransferInfo.Params = paramField;
Client.Network.SendPacket(request, transfer.Simulator);
- return transfer.ID;
}
///
@@ -489,7 +503,7 @@ namespace OpenMetaverse
/// The owner of this asset
/// Asset type
/// Whether to prioritize this asset download or not
- public UUID RequestInventoryAsset(UUID assetID, UUID itemID, UUID taskID, UUID ownerID, AssetType type, bool priority)
+ public void RequestInventoryAsset(UUID assetID, UUID itemID, UUID taskID, UUID ownerID, AssetType type, bool priority, AssetReceivedCallback callback)
{
AssetDownload transfer = new AssetDownload();
transfer.ID = UUID.Random();
@@ -499,6 +513,25 @@ namespace OpenMetaverse
transfer.Channel = ChannelType.Asset;
transfer.Source = SourceType.SimInventoryItem;
transfer.Simulator = Client.Network.CurrentSim;
+ transfer.Callback = callback;
+
+ // Check asset cache first
+ if (callback != null && Cache.HasAsset(assetID))
+ {
+ byte[] data = Cache.GetCachedAssetBytes(assetID);
+ transfer.AssetData = data;
+ transfer.Success = true;
+ transfer.Status = StatusCode.OK;
+
+ Asset asset = CreateAssetWrapper(type);
+ asset.AssetData = data;
+ asset.AssetID = assetID;
+
+ try { callback(transfer, asset); }
+ catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
+
+ return;
+ }
// Add this transfer to the dictionary
lock (Transfers) Transfers[transfer.ID] = transfer;
@@ -521,12 +554,11 @@ namespace OpenMetaverse
request.TransferInfo.Params = paramField;
Client.Network.SendPacket(request, transfer.Simulator);
- return transfer.ID;
}
- public UUID RequestInventoryAsset(InventoryItem item, bool priority)
+ public void RequestInventoryAsset(InventoryItem item, bool priority, AssetReceivedCallback callback)
{
- return RequestInventoryAsset(item.AssetUUID, item.UUID, UUID.Zero, item.OwnerID, item.AssetType, priority);
+ RequestInventoryAsset(item.AssetUUID, item.UUID, UUID.Zero, item.OwnerID, item.AssetType, priority, callback);
}
public void RequestEstateAsset()
@@ -933,77 +965,76 @@ namespace OpenMetaverse
private void TransferInfoHandler(Packet packet, Simulator simulator)
{
- if (OnAssetReceived != null)
+ TransferInfoPacket info = (TransferInfoPacket)packet;
+ Transfer transfer;
+ AssetDownload download;
+
+ if (Transfers.TryGetValue(info.TransferInfo.TransferID, out transfer))
{
- TransferInfoPacket info = (TransferInfoPacket)packet;
- Transfer transfer;
- AssetDownload download;
+ download = (AssetDownload)transfer;
- if (Transfers.TryGetValue(info.TransferInfo.TransferID, out transfer))
+ if (download.Callback == null) return;
+
+ download.Channel = (ChannelType)info.TransferInfo.ChannelType;
+ download.Status = (StatusCode)info.TransferInfo.Status;
+ download.Target = (TargetType)info.TransferInfo.TargetType;
+ download.Size = info.TransferInfo.Size;
+
+ // TODO: Once we support mid-transfer status checking and aborting this
+ // will need to become smarter
+ if (download.Status != StatusCode.OK)
{
- download = (AssetDownload)transfer;
+ Logger.Log("Transfer failed with status code " + download.Status, Helpers.LogLevel.Warning, Client);
- download.Channel = (ChannelType)info.TransferInfo.ChannelType;
- download.Status = (StatusCode)info.TransferInfo.Status;
- download.Target = (TargetType)info.TransferInfo.TargetType;
- download.Size = info.TransferInfo.Size;
+ lock (Transfers) Transfers.Remove(download.ID);
- // TODO: Once we support mid-transfer status checking and aborting this
- // will need to become smarter
- if (download.Status != StatusCode.OK)
- {
- Logger.Log("Transfer failed with status code " + download.Status, Helpers.LogLevel.Warning, Client);
+ // No data could have been received before the TransferInfo packet
+ download.AssetData = null;
- lock (Transfers) Transfers.Remove(download.ID);
-
- // No data could have been received before the TransferInfo packet
- download.AssetData = null;
-
- // Fire the event with our transfer that contains Success = false;
- try { OnAssetReceived(download, null); }
- catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
- }
- else
- {
- download.AssetData = new byte[download.Size];
-
- if (download.Source == SourceType.Asset && info.TransferInfo.Params.Length == 20)
- {
- download.AssetID = new UUID(info.TransferInfo.Params, 0);
- download.AssetType = (AssetType)(sbyte)info.TransferInfo.Params[16];
-
- //Client.DebugLog(String.Format("TransferInfo packet received. AssetID: {0} Type: {1}",
- // transfer.AssetID, type));
- }
- else if (download.Source == SourceType.SimInventoryItem && info.TransferInfo.Params.Length == 100)
- {
- // TODO: Can we use these?
- //UUID agentID = new UUID(info.TransferInfo.Params, 0);
- //UUID sessionID = new UUID(info.TransferInfo.Params, 16);
- //UUID ownerID = new UUID(info.TransferInfo.Params, 32);
- //UUID taskID = new UUID(info.TransferInfo.Params, 48);
- //UUID itemID = new UUID(info.TransferInfo.Params, 64);
- download.AssetID = new UUID(info.TransferInfo.Params, 80);
- download.AssetType = (AssetType)(sbyte)info.TransferInfo.Params[96];
-
- //Client.DebugLog(String.Format("TransferInfo packet received. AgentID: {0} SessionID: {1} " +
- // "OwnerID: {2} TaskID: {3} ItemID: {4} AssetID: {5} Type: {6}", agentID, sessionID,
- // ownerID, taskID, itemID, transfer.AssetID, type));
- }
- else
- {
- Logger.Log("Received a TransferInfo packet with a SourceType of " + download.Source.ToString() +
- " and a Params field length of " + info.TransferInfo.Params.Length,
- Helpers.LogLevel.Warning, Client);
- }
- }
+ // Fire the event with our transfer that contains Success = false;
+ try { download.Callback(download, null); }
+ catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
}
else
{
- Logger.Log("Received a TransferInfo packet for an asset we didn't request, TransferID: " +
- info.TransferInfo.TransferID, Helpers.LogLevel.Warning, Client);
+ download.AssetData = new byte[download.Size];
+
+ if (download.Source == SourceType.Asset && info.TransferInfo.Params.Length == 20)
+ {
+ download.AssetID = new UUID(info.TransferInfo.Params, 0);
+ download.AssetType = (AssetType)(sbyte)info.TransferInfo.Params[16];
+
+ //Client.DebugLog(String.Format("TransferInfo packet received. AssetID: {0} Type: {1}",
+ // transfer.AssetID, type));
+ }
+ else if (download.Source == SourceType.SimInventoryItem && info.TransferInfo.Params.Length == 100)
+ {
+ // TODO: Can we use these?
+ //UUID agentID = new UUID(info.TransferInfo.Params, 0);
+ //UUID sessionID = new UUID(info.TransferInfo.Params, 16);
+ //UUID ownerID = new UUID(info.TransferInfo.Params, 32);
+ //UUID taskID = new UUID(info.TransferInfo.Params, 48);
+ //UUID itemID = new UUID(info.TransferInfo.Params, 64);
+ download.AssetID = new UUID(info.TransferInfo.Params, 80);
+ download.AssetType = (AssetType)(sbyte)info.TransferInfo.Params[96];
+
+ //Client.DebugLog(String.Format("TransferInfo packet received. AgentID: {0} SessionID: {1} " +
+ // "OwnerID: {2} TaskID: {3} ItemID: {4} AssetID: {5} Type: {6}", agentID, sessionID,
+ // ownerID, taskID, itemID, transfer.AssetID, type));
+ }
+ else
+ {
+ Logger.Log("Received a TransferInfo packet with a SourceType of " + download.Source.ToString() +
+ " and a Params field length of " + info.TransferInfo.Params.Length,
+ Helpers.LogLevel.Warning, Client);
+ }
}
}
+ else
+ {
+ Logger.Log("Received a TransferInfo packet for an asset we didn't request, TransferID: " +
+ info.TransferInfo.TransferID, Helpers.LogLevel.Warning, Client);
+ }
}
private void TransferPacketHandler(Packet packet, Simulator simulator)
@@ -1038,9 +1069,9 @@ namespace OpenMetaverse
lock (Transfers) Transfers.Remove(download.ID);
// Fire the event with our transfer that contains Success = false
- if (OnAssetReceived != null)
+ if (download.Callback != null)
{
- try { OnAssetReceived(download, null); }
+ try { download.Callback(download, null); }
catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
}
@@ -1075,9 +1106,12 @@ namespace OpenMetaverse
download.Success = true;
lock (Transfers) Transfers.Remove(download.ID);
- if (OnAssetReceived != null)
+ // Cache successful asset download
+ Cache.SaveAssetToCache(download.AssetID, download.AssetData);
+
+ if (download.Callback != null)
{
- try { OnAssetReceived(download, WrapAsset(download)); }
+ try { download.Callback(download, WrapAsset(download)); }
catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
}
}
diff --git a/OpenMetaverse/TexturePipeline.cs b/OpenMetaverse/TexturePipeline.cs
index 1d94d2ff..0e4d0052 100644
--- a/OpenMetaverse/TexturePipeline.cs
+++ b/OpenMetaverse/TexturePipeline.cs
@@ -281,11 +281,11 @@ namespace OpenMetaverse
if (callback != null)
{
- if (_Client.Assets.Cache.HasImage(textureID))
+ if (_Client.Assets.Cache.HasAsset(textureID))
{
ImageDownload image = new ImageDownload();
image.ID = textureID;
- image.AssetData = _Client.Assets.Cache.GetCachedImageBytes(textureID);
+ image.AssetData = _Client.Assets.Cache.GetCachedAssetBytes(textureID);
image.Size = image.AssetData.Length;
image.Transferred = image.AssetData.Length;
image.ImageType = imageType;
@@ -708,7 +708,7 @@ namespace OpenMetaverse
task.Transfer.Success = true;
_Transfers.Remove(task.Transfer.ID);
resetEvents[task.RequestSlot].Set(); // free up request slot
- _Client.Assets.Cache.SaveImageToCache(task.RequestID, task.Transfer.AssetData);
+ _Client.Assets.Cache.SaveAssetToCache(task.RequestID, task.Transfer.AssetData);
foreach (TextureDownloadCallback callback in task.Callbacks)
callback(TextureRequestState.Finished, new AssetTexture(task.RequestID, task.Transfer.AssetData));
@@ -790,7 +790,7 @@ namespace OpenMetaverse
_Transfers.Remove(task.RequestID);
resetEvents[task.RequestSlot].Set();
- _Client.Assets.Cache.SaveImageToCache(task.RequestID, task.Transfer.AssetData);
+ _Client.Assets.Cache.SaveAssetToCache(task.RequestID, task.Transfer.AssetData);
foreach (TextureDownloadCallback callback in task.Callbacks)
callback(TextureRequestState.Finished, new AssetTexture(task.RequestID, task.Transfer.AssetData));
diff --git a/Programs/PrimWorkshop/frmBrowser.cs b/Programs/PrimWorkshop/frmBrowser.cs
index 83a98765..db0d648d 100644
--- a/Programs/PrimWorkshop/frmBrowser.cs
+++ b/Programs/PrimWorkshop/frmBrowser.cs
@@ -356,7 +356,7 @@ namespace PrimWorkshop
// Copy all of relevant textures from the cache to the temp directory
foreach (UUID texture in textureList)
{
- string tempFileName = Client.Assets.Cache.ImageFileName(texture);
+ string tempFileName = Client.Assets.Cache.AssetFileName(texture);
if (!String.IsNullOrEmpty(tempFileName))
{
diff --git a/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs b/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs
index 03e51e54..4e79351a 100644
--- a/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs
+++ b/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs
@@ -15,7 +15,6 @@ namespace OpenMetaverse.TestClient
{
public class QueuedDownloadInfo
{
- public UUID TransferID;
public UUID AssetID;
public UUID ItemID;
public UUID TaskID;
@@ -33,7 +32,6 @@ namespace OpenMetaverse.TestClient
TaskID = task;
OwnerID = owner;
Type = type;
- TransferID = UUID.Zero;
WhenRequested = DateTime.Now;
IsRequested = false;
}
@@ -114,7 +112,6 @@ namespace OpenMetaverse.TestClient
{
Name = "backuptext";
Description = "Backup inventory to a folder on your hard drive. Usage: " + Name + " [to ] | [abort] | [status]";
- testClient.Assets.OnAssetReceived += new AssetManager.AssetReceivedCallback(Assets_OnAssetReceived);
}
public override string Execute(string[] args, UUID fromAgentID)
@@ -183,8 +180,8 @@ namespace OpenMetaverse.TestClient
{
Logger.DebugLog(Name + ": timeout on asset " + qdi.AssetID.ToString(), Client);
// submit request again
- qdi.TransferID = Client.Assets.RequestInventoryAsset(
- qdi.AssetID, qdi.ItemID, qdi.TaskID, qdi.OwnerID, qdi.Type, true);
+ Client.Assets.RequestInventoryAsset(
+ qdi.AssetID, qdi.ItemID, qdi.TaskID, qdi.OwnerID, qdi.Type, true, Assets_OnAssetReceived);
qdi.WhenRequested = DateTime.Now;
qdi.IsRequested = true;
}
@@ -200,8 +197,8 @@ namespace OpenMetaverse.TestClient
QueuedDownloadInfo qdi = PendingDownloads.Dequeue();
qdi.WhenRequested = DateTime.Now;
qdi.IsRequested = true;
- qdi.TransferID = Client.Assets.RequestInventoryAsset(
- qdi.AssetID, qdi.ItemID, qdi.TaskID, qdi.OwnerID, qdi.Type, true);
+ Client.Assets.RequestInventoryAsset(
+ qdi.AssetID, qdi.ItemID, qdi.TaskID, qdi.OwnerID, qdi.Type, true, Assets_OnAssetReceived);
lock (CurrentDownloads) CurrentDownloads.Add(qdi);
}
@@ -316,10 +313,10 @@ namespace OpenMetaverse.TestClient
// see if we have this in our transfer list
QueuedDownloadInfo r = CurrentDownloads.Find(delegate(QueuedDownloadInfo q)
{
- return q.TransferID == asset.ID;
+ return q.AssetID == asset.AssetID;
});
- if (r != null && r.TransferID == asset.ID)
+ if (r != null && r.AssetID == asset.AssetID)
{
if (asset.Success)
{
diff --git a/Programs/examples/TestClient/Commands/Inventory/CreateNotecardCommand.cs b/Programs/examples/TestClient/Commands/Inventory/CreateNotecardCommand.cs
index d3a413c0..5c843f01 100644
--- a/Programs/examples/TestClient/Commands/Inventory/CreateNotecardCommand.cs
+++ b/Programs/examples/TestClient/Commands/Inventory/CreateNotecardCommand.cs
@@ -172,27 +172,19 @@ namespace OpenMetaverse.TestClient
byte[] notecardData = null;
string error = "Timeout";
- AssetManager.AssetReceivedCallback assetCallback =
- delegate(AssetDownload transfer, Asset asset)
- {
- if (transfer.ID == transferID)
- {
- if (transfer.Success)
- notecardData = transfer.AssetData;
- else
- error = transfer.Status.ToString();
- assetDownloadEvent.Set();
- }
- };
-
- Client.Assets.OnAssetReceived += assetCallback;
-
- transferID = Client.Assets.RequestInventoryAsset(assetID, itemID, UUID.Zero, Client.Self.AgentID, AssetType.Notecard, true);
+ Client.Assets.RequestInventoryAsset(assetID, itemID, UUID.Zero, Client.Self.AgentID, AssetType.Notecard, true,
+ delegate(AssetDownload transfer, Asset asset)
+ {
+ if (transfer.Success)
+ notecardData = transfer.AssetData;
+ else
+ error = transfer.Status.ToString();
+ assetDownloadEvent.Set();
+ }
+ );
assetDownloadEvent.WaitOne(NOTECARD_FETCH_TIMEOUT, false);
- Client.Assets.OnAssetReceived -= assetCallback;
-
if (notecardData != null)
return Encoding.UTF8.GetString(notecardData);
else
diff --git a/Programs/examples/TestClient/Commands/Inventory/DownloadCommand.cs b/Programs/examples/TestClient/Commands/Inventory/DownloadCommand.cs
index 17d446e8..03f395c6 100644
--- a/Programs/examples/TestClient/Commands/Inventory/DownloadCommand.cs
+++ b/Programs/examples/TestClient/Commands/Inventory/DownloadCommand.cs
@@ -18,8 +18,6 @@ namespace OpenMetaverse.TestClient
Name = "download";
Description = "Downloads the specified asset. Usage: download [uuid] [assetType]";
Category = CommandCategory.Inventory;
-
- testClient.Assets.OnAssetReceived += new AssetManager.AssetReceivedCallback(Assets_OnAssetReceived);
}
public override string Execute(string[] args, UUID fromAgentID)
@@ -40,7 +38,7 @@ namespace OpenMetaverse.TestClient
assetType = (AssetType)typeInt;
// Start the asset download
- Client.Assets.RequestAsset(AssetID, assetType, true);
+ Client.Assets.RequestAsset(AssetID, assetType, true, Assets_OnAssetReceived);
if (DownloadHandle.WaitOne(120 * 1000, false))
{
diff --git a/Programs/examples/TestClient/Commands/Inventory/ViewNotecardCommand.cs b/Programs/examples/TestClient/Commands/Inventory/ViewNotecardCommand.cs
index 1a083139..adabc60f 100644
--- a/Programs/examples/TestClient/Commands/Inventory/ViewNotecardCommand.cs
+++ b/Programs/examples/TestClient/Commands/Inventory/ViewNotecardCommand.cs
@@ -42,35 +42,29 @@ namespace OpenMetaverse.TestClient
System.Text.StringBuilder result = new System.Text.StringBuilder();
-
- // define a delegate to handle the reply
- AssetManager.AssetReceivedCallback del = delegate(AssetDownload transfer, Asset asset)
- {
- if (transfer.Success)
- {
- result.AppendFormat("Raw Notecard Data: " + System.Environment.NewLine + " {0}", Utils.BytesToString(asset.AssetData));
- waitEvent.Set();
- }
- };
-
// verify asset is loaded in store
if (Client.Inventory.Store.Contains(note))
{
// retrieve asset from store
InventoryItem ii = (InventoryItem)Client.Inventory.Store[note];
- // subscribe to reply event
- Client.Assets.OnAssetReceived += del;
// make request for asset
- Client.Assets.RequestInventoryAsset(ii, true);
+ Client.Assets.RequestInventoryAsset(ii, true,
+ delegate(AssetDownload transfer, Asset asset)
+ {
+ if (transfer.Success)
+ {
+ result.AppendFormat("Raw Notecard Data: " + System.Environment.NewLine + " {0}", Utils.BytesToString(asset.AssetData));
+ waitEvent.Set();
+ }
+ }
+ );
// wait for reply or timeout
if (!waitEvent.WaitOne(10000, false))
{
result.Append("Timeout waiting for notecard to download.");
}
- // unsubscribe from reply event
- Client.Assets.OnAssetReceived -= del;
}
else
{