Files
libremetaverse/Programs/examples/TestClient/Commands/Friends/FriendsCommand.cs
Latif Khalifa 64417a208a LIBOMV-630: TestClient improvements (patch by Kephra Nurmi)
Improved TestClient:
added '@' as a command prefix to target one avatar only and to check, if a named avatar is logged in.

Improved TestClient to add new commands:

groupmembers GroupnameOrUUID - shows groupmembers UUIDs
grouproles GroupnameOrUUID - shows grouproles UUID and Names
invitegroup AvatarUUID GroupUUID RoleUUID* - invites an avatar into a group (without querying groupmembers first !-)

added public Dictionary<UUID, Group> GroupsCache = null; to TestClient.cs to refactor copy and paste code of group commands.
added friend.UUID to output of FriendsCommand.cs
swapped output of UUID and name in GroupsCommand.cs



git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2989 52acb1d6-8a22-11de-b505-999d5b087335
2009-07-15 23:23:11 +00:00

64 lines
2.3 KiB
C#

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
{
/// <summary>
/// Shows a list of friends
/// </summary>
public class FriendsCommand : Command
{
/// <summary>
/// Constructor for FriendsCommand class
/// </summary>
/// <param name="testClient">A reference to the TestClient object</param>
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;
}
/// <summary>
/// Get a list of current friends
/// </summary>
/// <param name="args">optional testClient command arguments</param>
/// <param name="fromAgentID">The <seealso cref="OpenMetaverse.UUID"/>
/// of the agent making the request</param>
/// <returns></returns>
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();
}
}
}