LIBOMV-639:
* Renamed TextureCache to AssetCache * Plugged in new cache into AssetManager * Removed OnAssetReceived global event from AssetManger * RequestAsset and RequestInventoryAsset now take a delegate of type AssetReceivedCallback git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3004 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -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 <directory>] | [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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user