2025-01-13 07:44:05 -06:00
|
|
|
using System;
|
2009-05-12 00:07:35 +00:00
|
|
|
using OpenMetaverse.Assets;
|
2008-09-12 23:46:28 +00:00
|
|
|
|
|
|
|
|
namespace OpenMetaverse.TestClient
|
|
|
|
|
{
|
|
|
|
|
public class ViewNotecardCommand : Command
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// TestClient command to download and display a notecard asset
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="testClient"></param>
|
|
|
|
|
public ViewNotecardCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
Name = "viewnote";
|
|
|
|
|
Description = "Downloads and displays a notecard asset";
|
|
|
|
|
Category = CommandCategory.Inventory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-11-16 08:39:23 -06:00
|
|
|
/// Execute the command
|
2008-09-12 23:46:28 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args"></param>
|
|
|
|
|
/// <param name="fromAgentID"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public override string Execute(string[] args, UUID fromAgentID)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (args.Length < 1)
|
|
|
|
|
{
|
|
|
|
|
return "Usage: viewnote [notecard asset uuid]";
|
|
|
|
|
}
|
|
|
|
|
UUID note;
|
|
|
|
|
if (!UUID.TryParse(args[0], out note))
|
|
|
|
|
{
|
|
|
|
|
return "First argument expected agent UUID.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.Threading.AutoResetEvent waitEvent = new System.Threading.AutoResetEvent(false);
|
|
|
|
|
|
|
|
|
|
System.Text.StringBuilder result = new System.Text.StringBuilder();
|
|
|
|
|
|
|
|
|
|
// verify asset is loaded in store
|
|
|
|
|
if (Client.Inventory.Store.Contains(note))
|
|
|
|
|
{
|
|
|
|
|
// retrieve asset from store
|
|
|
|
|
InventoryItem ii = (InventoryItem)Client.Inventory.Store[note];
|
|
|
|
|
|
|
|
|
|
// make request for asset
|
2020-09-03 05:47:12 +03:00
|
|
|
var transferID = UUID.Random();
|
|
|
|
|
Client.Assets.RequestInventoryAsset(ii, true, transferID,
|
2009-07-19 03:38:27 +00:00
|
|
|
delegate(AssetDownload transfer, Asset asset)
|
|
|
|
|
{
|
|
|
|
|
if (transfer.Success)
|
|
|
|
|
{
|
|
|
|
|
result.AppendFormat("Raw Notecard Data: " + System.Environment.NewLine + " {0}", Utils.BytesToString(asset.AssetData));
|
|
|
|
|
waitEvent.Set();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2008-09-12 23:46:28 +00:00
|
|
|
|
|
|
|
|
// wait for reply or timeout
|
2025-01-13 07:44:05 -06:00
|
|
|
if (!waitEvent.WaitOne(TimeSpan.FromSeconds(10), false))
|
2008-09-12 23:46:28 +00:00
|
|
|
{
|
|
|
|
|
result.Append("Timeout waiting for notecard to download.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.Append("Cannot find asset in inventory store, use 'i' to populate store");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// return results
|
|
|
|
|
return result.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|