Files
libremetaverse/Programs/examples/TestClient/Commands/Groups/GroupsCommand.cs
Jim Radford 6f11b53860 TC-45 New TestClient command selectobjects - will return a list of objects on a specific parcel owned by the specifed owner
TC-44 New TestClient command ownerprims to display prim counts
TC-43 Overhaul TestClient help menu system

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@2000 52acb1d6-8a22-11de-b505-999d5b087335
2008-07-25 08:55:36 +00:00

58 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading;
using OpenMetaverse;
using OpenMetaverse.Packets;
using System.Text;
namespace OpenMetaverse.TestClient
{
public class GroupsCommand : Command
{
ManualResetEvent GetCurrentGroupsEvent = new ManualResetEvent(false);
Dictionary<UUID, Group> groups = new Dictionary<UUID, Group>();
public GroupsCommand(TestClient testClient)
{
testClient.Groups.OnCurrentGroups += new GroupManager.CurrentGroupsCallback(Groups_OnCurrentGroups);
Name = "groups";
Description = "List avatar groups. Usage: groups";
Category = CommandCategory.Groups;
}
public override string Execute(string[] args, UUID fromAgentID)
{
if (groups.Count == 0)
{
Client.Groups.RequestCurrentGroups();
GetCurrentGroupsEvent.WaitOne(10000, false);
}
if (groups.Count > 0)
{
return getGroupsString();
}
else
{
return "No groups";
}
}
void Groups_OnCurrentGroups(Dictionary<UUID, Group> pGroups)
{
groups = pGroups;
GetCurrentGroupsEvent.Set();
}
string getGroupsString()
{
StringBuilder sb = new StringBuilder();
foreach (Group group in groups.Values)
{
sb.AppendLine(group.Name + " " + group.ID);
}
return sb.ToString();
}
}
}