2009-10-08 02:56:37 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
namespace OpenMetaverse.TestClient.Commands
|
|
|
|
|
|
{
|
|
|
|
|
|
class SearchPlacesCommand : Command
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false);
|
|
|
|
|
|
|
|
|
|
|
|
public SearchPlacesCommand(TestClient testClient)
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "searchplaces";
|
|
|
|
|
|
Description = "Searches Places. Usage: searchplaces [search text]";
|
2009-10-17 05:50:51 +00:00
|
|
|
|
Category = CommandCategory.Search;
|
2009-10-08 02:56:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string Execute(string[] args, UUID fromAgentID)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (args.Length < 1)
|
|
|
|
|
|
return "Usage: searchplaces [search text]";
|
|
|
|
|
|
|
|
|
|
|
|
string searchText = string.Empty;
|
|
|
|
|
|
for (int i = 0; i < args.Length; i++)
|
|
|
|
|
|
searchText += args[i] + " ";
|
|
|
|
|
|
searchText = searchText.TrimEnd();
|
|
|
|
|
|
waitQuery.Reset();
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder result = new StringBuilder();
|
2009-10-10 06:38:07 +00:00
|
|
|
|
|
|
|
|
|
|
EventHandler<PlacesReplyEventArgs> callback = delegate(object sender, PlacesReplyEventArgs e)
|
2009-10-08 02:56:37 +00:00
|
|
|
|
{
|
|
|
|
|
|
result.AppendFormat("Your search string '{0}' returned {1} results" + System.Environment.NewLine,
|
2009-10-10 06:38:07 +00:00
|
|
|
|
searchText, e.MatchedPlaces.Count);
|
|
|
|
|
|
foreach (DirectoryManager.PlacesSearchData place in e.MatchedPlaces)
|
2009-10-08 02:56:37 +00:00
|
|
|
|
{
|
|
|
|
|
|
result.AppendLine(place.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
waitQuery.Set();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2009-10-10 06:38:07 +00:00
|
|
|
|
Client.Directory.PlacesReply += callback;
|
|
|
|
|
|
Client.Directory.StartPlacesSearch(searchText);
|
2009-10-08 02:56:37 +00:00
|
|
|
|
|
|
|
|
|
|
if (!waitQuery.WaitOne(20000, false) && Client.Network.Connected)
|
|
|
|
|
|
{
|
|
|
|
|
|
result.AppendLine("Timeout waiting for simulator to respond to query.");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-10-10 06:38:07 +00:00
|
|
|
|
Client.Directory.PlacesReply -= callback;
|
2009-10-08 02:56:37 +00:00
|
|
|
|
|
|
|
|
|
|
return result.ToString();
|
2009-10-10 06:38:07 +00:00
|
|
|
|
}
|
2009-10-08 02:56:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|