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 SearchGroupsCommand : Command |
||
8 | { |
||
9 | System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false); |
||
10 | int resultCount = 0; |
||
11 | |||
12 | public SearchGroupsCommand(TestClient testClient) |
||
13 | { |
||
14 | Name = "searchgroups"; |
||
15 | Description = "Searches groups. Usage: searchgroups [search text]"; |
||
16 | Category = CommandCategory.Groups; |
||
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: searchgroups [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 | Client.Directory.DirGroupsReply += Directory_DirGroups; |
||
33 | |||
34 | // send the request to the directory manager |
||
35 | Client.Directory.StartGroupSearch(searchText, 0); |
||
36 | |||
37 | string result; |
||
38 | if (waitQuery.WaitOne(20000, false) && Client.Network.Connected) |
||
39 | { |
||
40 | result = "Your query '" + searchText + "' matched " + resultCount + " Groups. "; |
||
41 | } |
||
42 | else |
||
43 | { |
||
44 | result = "Timeout waiting for simulator to respond."; |
||
45 | } |
||
46 | |||
47 | Client.Directory.DirGroupsReply -= Directory_DirGroups; |
||
48 | |||
49 | return result; |
||
50 | } |
||
51 | |||
52 | void Directory_DirGroups(object sender, DirGroupsReplyEventArgs e) |
||
53 | { |
||
54 | if (e.MatchedGroups.Count > 0) |
||
55 | { |
||
56 | foreach (DirectoryManager.GroupSearchData group in e.MatchedGroups) |
||
57 | { |
||
58 | Console.WriteLine("Group {1} ({0}) has {2} members", group.GroupID, group.GroupName, group.Members); |
||
59 | } |
||
60 | } |
||
61 | else |
||
62 | { |
||
63 | Console.WriteLine("Didn't find any groups that matched your query :("); |
||
64 | } |
||
65 | waitQuery.Set(); |
||
66 | } |
||
67 | } |
||
68 | } |