2025-01-13 07:44:05 -06:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2009-10-17 05:50:51 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
namespace OpenMetaverse.TestClient.Commands
|
|
|
|
|
|
{
|
|
|
|
|
|
class key2nameCommand : Command
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false);
|
|
|
|
|
|
StringBuilder result = new StringBuilder();
|
|
|
|
|
|
public key2nameCommand(TestClient testClient)
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "key2name";
|
|
|
|
|
|
Description = "resolve a UUID to an avatar or group name. Usage: key2name UUID";
|
|
|
|
|
|
Category = CommandCategory.Search;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string Execute(string[] args, UUID fromAgentID)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (args.Length < 1)
|
|
|
|
|
|
return "Usage: key2name UUID";
|
|
|
|
|
|
|
|
|
|
|
|
UUID key;
|
|
|
|
|
|
if(!UUID.TryParse(args[0].Trim(), out key))
|
|
|
|
|
|
{
|
|
|
|
|
|
return "UUID " + args[0].Trim() + " appears to be invalid";
|
|
|
|
|
|
}
|
|
|
|
|
|
result.Remove(0, result.Length);
|
|
|
|
|
|
waitQuery.Reset();
|
|
|
|
|
|
|
2009-10-22 04:29:25 +00:00
|
|
|
|
Client.Avatars.UUIDNameReply += Avatars_OnAvatarNames;
|
2009-10-20 20:18:03 +00:00
|
|
|
|
Client.Groups.GroupProfile += Groups_OnGroupProfile;
|
2009-10-17 05:50:51 +00:00
|
|
|
|
Client.Avatars.RequestAvatarName(key);
|
|
|
|
|
|
|
|
|
|
|
|
Client.Groups.RequestGroupProfile(key);
|
2025-01-13 07:44:05 -06:00
|
|
|
|
if (!waitQuery.WaitOne(TimeSpan.FromSeconds(10), false))
|
2009-10-17 05:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
result.AppendLine("Timeout waiting for reply, this could mean the Key is not an avatar or a group");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-10-22 04:29:25 +00:00
|
|
|
|
Client.Avatars.UUIDNameReply -= Avatars_OnAvatarNames;
|
2009-10-20 20:18:03 +00:00
|
|
|
|
Client.Groups.GroupProfile -= Groups_OnGroupProfile;
|
2009-10-17 05:50:51 +00:00
|
|
|
|
return result.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-10-20 20:18:03 +00:00
|
|
|
|
void Groups_OnGroupProfile(object sender, GroupProfileEventArgs e)
|
2009-10-17 05:50:51 +00:00
|
|
|
|
{
|
2009-10-20 20:18:03 +00:00
|
|
|
|
result.AppendLine("Group: " + e.Group.Name + " " + e.Group.ID);
|
2009-10-17 05:50:51 +00:00
|
|
|
|
waitQuery.Set();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-10-22 04:29:25 +00:00
|
|
|
|
void Avatars_OnAvatarNames(object sender, UUIDNameReplyEventArgs e)
|
2009-10-17 05:50:51 +00:00
|
|
|
|
{
|
2009-10-22 04:29:25 +00:00
|
|
|
|
foreach (KeyValuePair<UUID, string> kvp in e.Names)
|
2009-10-17 05:50:51 +00:00
|
|
|
|
result.AppendLine("Avatar: " + kvp.Value + " " + kvp.Key);
|
|
|
|
|
|
waitQuery.Set();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|