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 System.Threading;
4 using OpenMetaverse;
5 using OpenMetaverse.Packets;
6 using System.Text;
7  
8 // the Namespace used for all TestClient commands
9 namespace OpenMetaverse.TestClient
10 {
11 /// <summary>
12 /// Shows a list of friends
13 /// </summary>
14 public class FriendsCommand : Command
15 {
16 /// <summary>
17 /// Constructor for FriendsCommand class
18 /// </summary>
19 /// <param name="testClient">A reference to the TestClient object</param>
20 public FriendsCommand(TestClient testClient)
21 {
22 // The name of the command
23 Name = "friends";
24 // A short description of the command with usage instructions
25 Description = "List avatar friends. Usage: friends";
26 Category = CommandCategory.Friends;
27 }
28  
29 /// <summary>
30 /// Get a list of current friends
31 /// </summary>
32 /// <param name="args">optional testClient command arguments</param>
33 /// <param name="fromAgentID">The <seealso cref="OpenMetaverse.UUID"/>
34 /// of the agent making the request</param>
35 /// <returns></returns>
36 public override string Execute(string[] args, UUID fromAgentID)
37 {
38 // initialize a StringBuilder object used to return the results
39 StringBuilder sb = new StringBuilder();
40  
41 // Only iterate the Friends dictionary if we actually have friends!
42 if (Client.Friends.FriendList.Count > 0)
43 {
44 // iterate over the InternalDictionary using a delegate to populate
45 // our StringBuilder output string
46 sb.AppendFormat("has {0} friends:", Client.Friends.FriendList.Count).AppendLine();
47 Client.Friends.FriendList.ForEach(delegate(FriendInfo friend)
48 {
49 // append the name of the friend to our output
50 sb.AppendFormat("{0}, {1}", friend.UUID, friend.Name).AppendLine();
51 });
52 }
53 else
54 {
55 // we have no friends :(
56 sb.AppendLine("No Friends");
57 }
58  
59 // return the result
60 return sb.ToString();
61 }
62 }
63 }