* Added support for people directory searches [acidie]
* TestClient tracks its master through name and UUID now, and verifies identify by UUID [acidie] * Objects.OnObjectProperties wasn't hooked up to a packet callback previously, fixed now * Cleaned up the name2key example [acidie] git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1138 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
|
||||
@@ -9,11 +10,15 @@ namespace libsecondlife.TestClient
|
||||
public class SetMasterCommand: Command
|
||||
{
|
||||
public DateTime Created = DateTime.Now;
|
||||
private LLUUID resolvedMasterKey = LLUUID.Zero;
|
||||
private ManualResetEvent keyResolution = new ManualResetEvent(false);
|
||||
private LLUUID query = LLUUID.Zero;
|
||||
|
||||
public SetMasterCommand(TestClient testClient)
|
||||
{
|
||||
Name = "setMaster";
|
||||
Description = "Sets the user name of the master user. The master user can IM to run commands.";
|
||||
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, LLUUID fromAgentID)
|
||||
@@ -21,18 +26,48 @@ namespace libsecondlife.TestClient
|
||||
string masterName = String.Empty;
|
||||
for (int ct = 0; ct < args.Length;ct++)
|
||||
masterName = masterName + args[ct] + " ";
|
||||
Client.Master = masterName.TrimEnd();
|
||||
masterName = masterName.TrimEnd();
|
||||
|
||||
if (masterName.Length == 0)
|
||||
return "Usage setMaster name";
|
||||
|
||||
DirectoryManager.DirPeopleReplyCallback callback = new DirectoryManager.DirPeopleReplyCallback(KeyResolvHandler);
|
||||
Client.Directory.OnDirPeopleReply += callback;
|
||||
query = Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, masterName);
|
||||
if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false))
|
||||
{
|
||||
Client.MasterKey = resolvedMasterKey;
|
||||
keyResolution.Reset();
|
||||
Client.Directory.OnDirPeopleReply -= callback;
|
||||
}
|
||||
else
|
||||
{
|
||||
keyResolution.Reset();
|
||||
Client.Directory.OnDirPeopleReply -= callback;
|
||||
return "Unable to obtain UUID for \"" + masterName + "\". Master unchanged.";
|
||||
}
|
||||
|
||||
|
||||
foreach (Avatar av in Client.AvatarList.Values)
|
||||
{
|
||||
if (av.Name == Client.Master)
|
||||
if (av.ID == Client.MasterKey)
|
||||
{
|
||||
Client.Self.InstantMessage(av.ID, "You are now my master. IM me with \"help\" for a command list.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return "Master set to " + masterName;
|
||||
return "Master set to " + masterName + " (" + Client.MasterKey.ToStringHyphenated() + ")";
|
||||
}
|
||||
|
||||
private void KeyResolvHandler(LLUUID queryid, List<DirectoryManager.AgentSearchData> matches)
|
||||
{
|
||||
if (query != queryid)
|
||||
return;
|
||||
// We can't handle ambiguities here as nicely as we can in ClientManager.
|
||||
resolvedMasterKey = matches[0].AgentID;
|
||||
keyResolution.Set();
|
||||
query = LLUUID.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user