using System;
using System.Collections.Generic;
using System.Threading;
using OpenMetaverse;
using OpenMetaverse.Packets;
using System.Text;
// the Namespace used for all TestClient commands
namespace OpenMetaverse.TestClient
{
///
/// Shows a list of friends
///
public class FriendsCommand : Command
{
///
/// Constructor for FriendsCommand class
///
/// A reference to the TestClient object
public FriendsCommand(TestClient testClient)
{
// The name of the command
Name = "friends";
// A short description of the command with usage instructions
Description = "List avatar friends. Usage: friends";
Category = CommandCategory.Friends;
}
///
/// Get a list of current friends
///
/// optional testClient command arguments
/// The
/// of the agent making the request
///
public override string Execute(string[] args, UUID fromAgentID)
{
// initialize a StringBuilder object used to return the results
StringBuilder sb = new StringBuilder();
// Only iterate the Friends dictionary if we actually have friends!
if (Client.Friends.FriendList.Count > 0)
{
// iterate over the InternalDictionary using a delegate to populate
// our StringBuilder output string
sb.AppendFormat("has {0} friends:", Client.Friends.FriendList.Count).AppendLine();
Client.Friends.FriendList.ForEach(delegate(FriendInfo friend)
{
// append the name of the friend to our output
sb.AppendFormat("{0}, {1}", friend.UUID, friend.Name).AppendLine();
});
}
else
{
// we have no friends :(
sb.AppendLine("No Friends");
}
// return the result
return sb.ToString();
}
}
}