corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.Text; |
||
4 | |||
5 | namespace OpenMetaverse.TestClient.Commands |
||
6 | { |
||
7 | class SearchPeopleCommand : Command |
||
8 | { |
||
9 | System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false); |
||
10 | int resultCount = 0; |
||
11 | |||
12 | public SearchPeopleCommand(TestClient testClient) |
||
13 | { |
||
14 | Name = "searchpeople"; |
||
15 | Description = "Searches for other avatars. Usage: searchpeople [search text]"; |
||
16 | Category = CommandCategory.Search; |
||
17 | } |
||
18 | |||
19 | public override string Execute(string[] args, UUID fromAgentID) |
||
20 | { |
||
21 | // process command line arguments |
||
22 | if (args.Length < 1) |
||
23 | return "Usage: searchpeople [search text]"; |
||
24 | |||
25 | string searchText = string.Empty; |
||
26 | for (int i = 0; i < args.Length; i++) |
||
27 | searchText += args[i] + " "; |
||
28 | searchText = searchText.TrimEnd(); |
||
29 | |||
30 | waitQuery.Reset(); |
||
31 | |||
32 | |||
33 | Client.Directory.DirPeopleReply += Directory_DirPeople; |
||
34 | |||
35 | // send the request to the directory manager |
||
36 | Client.Directory.StartPeopleSearch(searchText, 0); |
||
37 | |||
38 | string result; |
||
39 | if (waitQuery.WaitOne(20000, false) && Client.Network.Connected) |
||
40 | { |
||
41 | result = "Your query '" + searchText + "' matched " + resultCount + " People. "; |
||
42 | } |
||
43 | else |
||
44 | { |
||
45 | result = "Timeout waiting for simulator to respond."; |
||
46 | } |
||
47 | |||
48 | Client.Directory.DirPeopleReply -= Directory_DirPeople; |
||
49 | |||
50 | return result; |
||
51 | } |
||
52 | |||
53 | void Directory_DirPeople(object sender, DirPeopleReplyEventArgs e) |
||
54 | { |
||
55 | if (e.MatchedPeople.Count > 0) |
||
56 | { |
||
57 | foreach (DirectoryManager.AgentSearchData agent in e.MatchedPeople) |
||
58 | { |
||
59 | Console.WriteLine("{0} {1} ({2})", agent.FirstName, agent.LastName, agent.AgentID); |
||
60 | } |
||
61 | } |
||
62 | else |
||
63 | { |
||
64 | Console.WriteLine("Didn't find any people that matched your query :("); |
||
65 | } |
||
66 | waitQuery.Set(); |
||
67 | } |
||
68 | } |
||
69 | } |