corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 using System;
2 using System.Collections.Generic;
3 using OpenMetaverse;
4 using OpenMetaverse.Packets;
5 using OpenMetaverse.Assets;
6  
7 namespace OpenMetaverse.TestClient
8 {
9 public class ViewNotecardCommand : Command
10 {
11 /// <summary>
12 /// TestClient command to download and display a notecard asset
13 /// </summary>
14 /// <param name="testClient"></param>
15 public ViewNotecardCommand(TestClient testClient)
16 {
17 Name = "viewnote";
18 Description = "Downloads and displays a notecard asset";
19 Category = CommandCategory.Inventory;
20 }
21  
22 /// <summary>
23 /// Exectute the command
24 /// </summary>
25 /// <param name="args"></param>
26 /// <param name="fromAgentID"></param>
27 /// <returns></returns>
28 public override string Execute(string[] args, UUID fromAgentID)
29 {
30  
31 if (args.Length < 1)
32 {
33 return "Usage: viewnote [notecard asset uuid]";
34 }
35 UUID note;
36 if (!UUID.TryParse(args[0], out note))
37 {
38 return "First argument expected agent UUID.";
39 }
40  
41 System.Threading.AutoResetEvent waitEvent = new System.Threading.AutoResetEvent(false);
42  
43 System.Text.StringBuilder result = new System.Text.StringBuilder();
44  
45 // verify asset is loaded in store
46 if (Client.Inventory.Store.Contains(note))
47 {
48 // retrieve asset from store
49 InventoryItem ii = (InventoryItem)Client.Inventory.Store[note];
50  
51 // make request for asset
52 Client.Assets.RequestInventoryAsset(ii, true,
53 delegate(AssetDownload transfer, Asset asset)
54 {
55 if (transfer.Success)
56 {
57 result.AppendFormat("Raw Notecard Data: " + System.Environment.NewLine + " {0}", Utils.BytesToString(asset.AssetData));
58 waitEvent.Set();
59 }
60 }
61 );
62  
63 // wait for reply or timeout
64 if (!waitEvent.WaitOne(10000, false))
65 {
66 result.Append("Timeout waiting for notecard to download.");
67 }
68 }
69 else
70 {
71 result.Append("Cannot find asset in inventory store, use 'i' to populate store");
72 }
73  
74 // return results
75 return result.ToString();
76 }
77 }
78 }