Files
libremetaverse/libsecondlife/examples/TestClient/Commands/Land/ParcelInfoCommand.cs
Jim Radford b4084c7b2e * Added overload to RequestAllSimParcels which allows user to do a full refresh of Parcel dictionary
* Increased time delay between requests due to caps being slower responding to parcel PropertiesRequests
* See TestClient/Commands/Land/ParcelInfoCommand.cs for example usage.

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1659 52acb1d6-8a22-11de-b505-999d5b087335
2008-03-07 17:43:51 +00:00

68 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using libsecondlife;
using libsecondlife.Utilities;
namespace libsecondlife.TestClient
{
public class ParcelInfoCommand : Command
{
private AutoResetEvent ParcelsDownloaded = new AutoResetEvent(false);
public ParcelInfoCommand(TestClient testClient)
{
Name = "parcelinfo";
Description = "Prints out info about all the parcels in this simulator";
testClient.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(Network_OnDisconnected);
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
StringBuilder sb = new StringBuilder();
string result;
ParcelManager.SimParcelsDownloaded del = delegate(Simulator simulator, InternalDictionary<int, Parcel> simParcels, int[,] parcelMap)
{
ParcelsDownloaded.Set();
};
ParcelsDownloaded.Reset();
Client.Parcels.OnSimParcelsDownloaded += del;
Client.Parcels.RequestAllSimParcels(Client.Network.CurrentSim);
if (Client.Network.CurrentSim.IsParcelMapFull())
ParcelsDownloaded.Set();
if (ParcelsDownloaded.WaitOne(20000, false) && Client.Network.Connected)
{
sb.AppendFormat("Downloaded {0} Parcels in {1}",
Client.Network.CurrentSim.Parcels.Count, Client.Network.CurrentSim.Name);
Client.Network.CurrentSim.Parcels.ForEach(delegate(Parcel parcel)
{
sb.AppendFormat("Parcels[{0}]: Name: \"{1}\", Description: \"{2}\" ACL Count: {3}" + System.Environment.NewLine,
parcel.LocalID, parcel.Name, parcel.Desc, parcel.AccessList.Count);
});
result = sb.ToString();
}
else
result = "Failed to retrieve information on all the simulator parcels";
Client.Parcels.OnSimParcelsDownloaded -= del;
return result;
}
void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message)
{
ParcelsDownloaded.Set();
}
}
}