2007-11-10 18:36:50 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
2008-07-21 21:12:59 +00:00
|
|
|
using OpenMetaverse;
|
|
|
|
|
using OpenMetaverse.Packets;
|
2007-11-10 18:36:50 +00:00
|
|
|
using System.Text;
|
|
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2007-11-10 18:36:50 +00:00
|
|
|
{
|
|
|
|
|
public class GroupsCommand : Command
|
|
|
|
|
{
|
|
|
|
|
ManualResetEvent GetCurrentGroupsEvent = new ManualResetEvent(false);
|
|
|
|
|
Dictionary<LLUUID, Group> groups = new Dictionary<LLUUID, Group>();
|
|
|
|
|
|
|
|
|
|
public GroupsCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
testClient.Groups.OnCurrentGroups += new GroupManager.CurrentGroupsCallback(Groups_OnCurrentGroups);
|
|
|
|
|
|
|
|
|
|
Name = "groups";
|
|
|
|
|
Description = "List avatar groups. Usage: groups";
|
|
|
|
|
}
|
|
|
|
|
public override string Execute(string[] args, LLUUID 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<LLUUID, Group> pGroups)
|
|
|
|
|
{
|
|
|
|
|
groups = pGroups;
|
|
|
|
|
GetCurrentGroupsEvent.Set();
|
|
|
|
|
}
|
|
|
|
|
string getGroupsString()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
foreach (Group group in groups.Values)
|
|
|
|
|
{
|
2008-01-05 23:30:50 +00:00
|
|
|
sb.AppendLine(group.Name + " " + group.ID);
|
|
|
|
|
|
2007-11-10 18:36:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|