Files
libremetaverse/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs
Jim Radford e09e3f45b3 LIBOMV-686 Implements new event patterns based on the Microsoft Framework Design Guidelines in ParcelManager
* Changes some public method names to match patterns used through library, namely requests that have an event are named with Request as a prefix
* Add Key2Name TestClient command for resolving group and avatar names based on a UUID
* BREAKING CHANGE * this is a major shift in the way events are internally handled.

git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3151 52acb1d6-8a22-11de-b505-999d5b087335
2009-10-17 05:50:51 +00:00

68 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using OpenMetaverse;
namespace OpenMetaverse.TestClient
{
public class ParcelSelectObjectsCommand : Command
{
public ParcelSelectObjectsCommand(TestClient testClient)
{
Name = "selectobjects";
Description = "Displays a list of prim localIDs on a given parcel with a specific owner. Usage: selectobjects parcelID OwnerUUID";
Category = CommandCategory.Parcel;
}
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length < 2)
return "Usage: selectobjects parcelID OwnerUUID (use parcelinfo to get ID, use parcelprimowners to get ownerUUID)";
int parcelID;
UUID ownerUUID;
int counter = 0;
StringBuilder result = new StringBuilder();
// test argument that is is a valid integer, then verify we have that parcel data stored in the dictionary
if (Int32.TryParse(args[0], out parcelID)
&& UUID.TryParse(args[1], out ownerUUID))
{
AutoResetEvent wait = new AutoResetEvent(false);
EventHandler<ForceSelectObjectsReplyEventArgs> callback = delegate(object sender, ForceSelectObjectsReplyEventArgs e)
{
for (int i = 0; i < e.ObjectIDs.Count; i++)
{
result.Append(e.ObjectIDs[i].ToString() + " ");
counter++;
}
if (e.ObjectIDs.Count < 251)
wait.Set();
};
Client.Parcels.ForceSelectObjectsReply += callback;
Client.Parcels.RequestSelectObjects(parcelID, (ObjectReturnType)16, ownerUUID);
Client.Parcels.RequestObjectOwners(Client.Network.CurrentSim, parcelID);
if (!wait.WaitOne(30000, false))
{
result.AppendLine("Timed out waiting for packet.");
}
Client.Parcels.ForceSelectObjectsReply -= callback;
result.AppendLine("Found a total of " + counter + " Objects");
return result.ToString();
}
else
{
return String.Format("Unable to find Parcel {0} in Parcels Dictionary, Did you run parcelinfo to populate the dictionary first?", args[0]);
}
}
}
}