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
This commit is contained in:
@@ -10,7 +10,6 @@ namespace OpenMetaverse.TestClient
|
||||
public class LeaveGroupCommand : Command
|
||||
{
|
||||
ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
Dictionary<UUID, Group> groups = new Dictionary<UUID, Group>();
|
||||
private bool leftGroup;
|
||||
|
||||
public LeaveGroupCommand(TestClient testClient)
|
||||
@@ -24,60 +23,30 @@ namespace OpenMetaverse.TestClient
|
||||
if (args.Length < 1)
|
||||
return Description;
|
||||
|
||||
groups.Clear();
|
||||
|
||||
string groupName = String.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
groupName += args[i] + " ";
|
||||
groupName = groupName.Trim();
|
||||
|
||||
GroupManager.CurrentGroupsCallback callback = new GroupManager.CurrentGroupsCallback(Groups_OnCurrentGroups);
|
||||
Client.Groups.OnCurrentGroups += callback;
|
||||
Client.Groups.RequestCurrentGroups();
|
||||
UUID groupUUID = Client.GroupName2UUID(groupName);
|
||||
if (UUID.Zero != groupUUID) {
|
||||
GroupManager.GroupLeftCallback lcallback = new GroupManager.GroupLeftCallback(Groups_OnGroupLeft);
|
||||
Client.Groups.OnGroupLeft += lcallback;
|
||||
Client.Groups.LeaveGroup(groupUUID);
|
||||
|
||||
GroupsEvent.WaitOne(30000, false);
|
||||
GroupsEvent.WaitOne(30000, false);
|
||||
|
||||
Client.Groups.OnCurrentGroups -= callback;
|
||||
GroupsEvent.Reset();
|
||||
Client.Groups.OnGroupLeft -= lcallback;
|
||||
GroupsEvent.Reset();
|
||||
Client.ReloadGroupsCache();
|
||||
|
||||
if (groups.Count > 0)
|
||||
{
|
||||
foreach (Group currentGroup in groups.Values)
|
||||
if (currentGroup.Name.ToLower() == groupName.ToLower())
|
||||
{
|
||||
GroupManager.GroupLeftCallback lcallback = new GroupManager.GroupLeftCallback(Groups_OnGroupLeft);
|
||||
Client.Groups.OnGroupLeft += lcallback;
|
||||
Client.Groups.LeaveGroup(currentGroup.ID);
|
||||
|
||||
/* A.Biondi
|
||||
* TODO: modify GroupsCommand.cs
|
||||
* GroupsCommand.cs doesn't refresh the groups list until a new
|
||||
* CurrentGroupsCallback occurs, so if you'd issue the command
|
||||
* 'Groups' right after have left a group, it'll display still yet
|
||||
* the group you just left (unless you have 0 groups, because it
|
||||
* would force the refresh with Client.Groups.RequestCurrentGroups).
|
||||
*/
|
||||
|
||||
GroupsEvent.WaitOne(30000, false);
|
||||
|
||||
Client.Groups.OnGroupLeft -= lcallback;
|
||||
GroupsEvent.Reset();
|
||||
|
||||
if (leftGroup)
|
||||
return Client.ToString() + " has left the group " + groupName;
|
||||
return "failed to left the group " + groupName;
|
||||
}
|
||||
return Client.ToString() + " doesn't seem to be member of the group " + groupName;
|
||||
if (leftGroup)
|
||||
return Client.ToString() + " has left the group " + groupName;
|
||||
return "failed to leave the group " + groupName;
|
||||
}
|
||||
|
||||
return Client.ToString() + " doesn't seem member of any group";
|
||||
return Client.ToString() + " doesn't seem to be member of the group " + groupName;
|
||||
}
|
||||
|
||||
void Groups_OnCurrentGroups(Dictionary<UUID, Group> cGroups)
|
||||
{
|
||||
groups = cGroups;
|
||||
GroupsEvent.Set();
|
||||
}
|
||||
|
||||
void Groups_OnGroupLeft(UUID groupID, bool success)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user