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:
Latif Khalifa
2009-07-15 23:23:11 +00:00
parent 31d313cdd4
commit 64417a208a
10 changed files with 295 additions and 115 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Reflection;
using System.Xml;
using OpenMetaverse;
@@ -26,6 +27,8 @@ namespace OpenMetaverse.TestClient
private System.Timers.Timer updateTimer;
private UUID GroupMembersRequestID;
public Dictionary<UUID, Group> GroupsCache = null;
private ManualResetEvent GroupsEvent = new ManualResetEvent(false);
/// <summary>
///
@@ -104,6 +107,47 @@ namespace OpenMetaverse.TestClient
}
}
public void ReloadGroupsCache()
{
GroupManager.CurrentGroupsCallback callback =
new GroupManager.CurrentGroupsCallback(Groups_OnCurrentGroups);
Groups.OnCurrentGroups += callback;
Groups.RequestCurrentGroups();
GroupsEvent.WaitOne(10000, false);
Groups.OnCurrentGroups -= callback;
GroupsEvent.Reset();
}
public UUID GroupName2UUID(String groupName)
{
UUID tryUUID;
if (UUID.TryParse(groupName,out tryUUID))
return tryUUID;
if (null == GroupsCache) {
ReloadGroupsCache();
if (null == GroupsCache)
return UUID.Zero;
}
lock(GroupsCache) {
if (GroupsCache.Count > 0) {
foreach (Group currentGroup in GroupsCache.Values)
if (currentGroup.Name.ToLower() == groupName.ToLower())
return currentGroup.ID;
}
}
return UUID.Zero;
}
private void Groups_OnCurrentGroups(Dictionary<UUID, Group> pGroups)
{
if (null == GroupsCache)
GroupsCache = pGroups;
else
lock(GroupsCache) { GroupsCache = pGroups; }
GroupsEvent.Set();
}
private void updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
foreach (Command c in Commands.Values)