aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/mass test client/Commands/System/SetMasterCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/mass test client/Commands/System/SetMasterCommand.cs73
1 files changed, 0 insertions, 73 deletions
diff --git a/tools/mass test client/Commands/System/SetMasterCommand.cs b/tools/mass test client/Commands/System/SetMasterCommand.cs
deleted file mode 100644
index 8601865..0000000
--- a/tools/mass test client/Commands/System/SetMasterCommand.cs
+++ /dev/null
@@ -1,73 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Threading;
5using libsecondlife;
6using libsecondlife.Packets;
7
8namespace libsecondlife.TestClient
9{
10 public class SetMasterCommand: Command
11 {
12 public DateTime Created = DateTime.Now;
13 private LLUUID resolvedMasterKey = LLUUID.Zero;
14 private ManualResetEvent keyResolution = new ManualResetEvent(false);
15 private LLUUID query = LLUUID.Zero;
16
17 public SetMasterCommand(TestClient testClient)
18 {
19 Name = "setMaster";
20 Description = "Sets the user name of the master user. The master user can IM to run commands.";
21
22 }
23
24 public override string Execute(string[] args, LLUUID fromAgentID)
25 {
26 string masterName = String.Empty;
27 for (int ct = 0; ct < args.Length;ct++)
28 masterName = masterName + args[ct] + " ";
29 masterName = masterName.TrimEnd();
30
31 if (masterName.Length == 0)
32 return "Usage setMaster name";
33
34 DirectoryManager.DirPeopleReplyCallback callback = new DirectoryManager.DirPeopleReplyCallback(KeyResolvHandler);
35 Client.Directory.OnDirPeopleReply += callback;
36 query = Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, masterName, 0);
37 if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false))
38 {
39 Client.MasterKey = resolvedMasterKey;
40 keyResolution.Reset();
41 Client.Directory.OnDirPeopleReply -= callback;
42 }
43 else
44 {
45 keyResolution.Reset();
46 Client.Directory.OnDirPeopleReply -= callback;
47 return "Unable to obtain UUID for \"" + masterName + "\". Master unchanged.";
48 }
49
50
51 foreach (Avatar av in Client.AvatarList.Values)
52 {
53 if (av.ID == Client.MasterKey)
54 {
55 Client.Self.InstantMessage(av.ID, "You are now my master. IM me with \"help\" for a command list.");
56 break;
57 }
58 }
59
60 return "Master set to " + masterName + " (" + Client.MasterKey.ToStringHyphenated() + ")";
61 }
62
63 private void KeyResolvHandler(LLUUID queryid, List<DirectoryManager.AgentSearchData> matches)
64 {
65 if (query != queryid)
66 return;
67 // We can't handle ambiguities here as nicely as we can in ClientManager.
68 resolvedMasterKey = matches[0].AgentID;
69 keyResolution.Set();
70 query = LLUUID.Zero;
71 }
72 }
73}