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
This commit is contained in:
Jim Radford
2009-10-17 05:50:51 +00:00
parent 7870cfb75f
commit e09e3f45b3
13 changed files with 737 additions and 328 deletions

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenMetaverse.TestClient.Commands
{
class key2nameCommand : Command
{
System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false);
StringBuilder result = new StringBuilder();
public key2nameCommand(TestClient testClient)
{
Name = "key2name";
Description = "resolve a UUID to an avatar or group name. Usage: key2name UUID";
Category = CommandCategory.Search;
}
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length < 1)
return "Usage: key2name UUID";
UUID key;
if(!UUID.TryParse(args[0].Trim(), out key))
{
return "UUID " + args[0].Trim() + " appears to be invalid";
}
result.Remove(0, result.Length);
waitQuery.Reset();
Client.Avatars.OnAvatarNames += Avatars_OnAvatarNames;
Client.Groups.OnGroupProfile += Groups_OnGroupProfile;
Client.Avatars.RequestAvatarName(key);
Client.Groups.RequestGroupProfile(key);
if (!waitQuery.WaitOne(10000, false))
{
result.AppendLine("Timeout waiting for reply, this could mean the Key is not an avatar or a group");
}
Client.Avatars.OnAvatarNames -= Avatars_OnAvatarNames;
Client.Groups.OnGroupProfile -= Groups_OnGroupProfile;
return result.ToString();
}
void Groups_OnGroupProfile(Group group)
{
result.AppendLine("Group: " + group.Name + " " + group.ID);
waitQuery.Set();
}
void Avatars_OnAvatarNames(Dictionary<UUID, string> names)
{
foreach (KeyValuePair<UUID, string> kvp in names)
result.AppendLine("Avatar: " + kvp.Value + " " + kvp.Key);
waitQuery.Set();
}
}
}

View File

@@ -12,7 +12,7 @@ namespace OpenMetaverse.TestClient.Commands
{
Name = "searchclassifieds";
Description = "Searches Classified Ads. Usage: searchclassifieds [search text]";
Category = CommandCategory.Other;
Category = CommandCategory.Search;
}
public override string Execute(string[] args, UUID fromAgentID)

View File

@@ -13,7 +13,7 @@ namespace OpenMetaverse.TestClient.Commands
{
Name = "searchevents";
Description = "Searches Events list. Usage: searchevents [search text]";
Category = CommandCategory.Other;
Category = CommandCategory.Search;
}
public override string Execute(string[] args, UUID fromAgentID)

View File

@@ -13,7 +13,7 @@ namespace OpenMetaverse.TestClient.Commands
{
Name = "searchpeople";
Description = "Searches for other avatars. Usage: searchpeople [search text]";
Category = CommandCategory.Friends;
Category = CommandCategory.Search;
}
public override string Execute(string[] args, UUID fromAgentID)

View File

@@ -12,7 +12,7 @@ namespace OpenMetaverse.TestClient.Commands
{
Name = "searchplaces";
Description = "Searches Places. Usage: searchplaces [search text]";
Category = CommandCategory.Other;
Category = CommandCategory.Search;
}
public override string Execute(string[] args, UUID fromAgentID)

View File

@@ -18,7 +18,7 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell
{
if (args.Length < 2)
{
return "Usage: give <agent uuid> <item1> [item2] [item3] [...]";
return "Usage: give <agent uuid> itemname";
}
UUID dest;
if (!UUID.TryParse(args[0], out dest))
@@ -29,32 +29,36 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell
Inventory = Manager.Store;
string ret = "";
string nl = "\n";
for (int i = 1; i < args.Length; ++i)
string target = String.Empty;
for (int ct = 0; ct < args.Length; ct++)
target = target + args[ct] + " ";
target = target.TrimEnd();
string inventoryName = target;
// WARNING: Uses local copy of inventory contents, need to download them first.
List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
bool found = false;
foreach (InventoryBase b in contents)
{
string inventoryName = args[i];
// WARNING: Uses local copy of inventory contents, need to download them first.
List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
bool found = false;
foreach (InventoryBase b in contents)
if (inventoryName == b.Name || inventoryName == b.UUID.ToString())
{
if (inventoryName == b.Name || inventoryName == b.UUID.ToString())
found = true;
if (b is InventoryItem)
{
found = true;
if (b is InventoryItem)
{
InventoryItem item = b as InventoryItem;
Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true);
ret += "Gave " + item.Name + nl;
}
else
{
ret += "Unable to give folder " + b.Name + nl;
}
InventoryItem item = b as InventoryItem;
Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true);
ret += "Gave " + item.Name + " (" + item.AssetType + ")" + nl;
}
else
{
ret += "Unable to give folder " + b.Name + nl;
}
}
if (!found)
ret += "No inventory item named " + inventoryName + " found." + nl;
}
if (!found)
ret += "No inventory item named " + inventoryName + " found." + nl;
return ret;
}
}

View File

@@ -27,7 +27,7 @@ namespace OpenMetaverse.TestClient
if (Int32.TryParse(args[0], out parcelID) && Client.Network.CurrentSim.Parcels.TryGetValue(parcelID, out parcel))
{
// this request will update the parcels dictionary
Client.Parcels.PropertiesRequest(Client.Network.CurrentSim, parcelID, 0);
Client.Parcels.RequestParcelProperties(Client.Network.CurrentSim, parcelID, 0);
// Use reflection to dynamically get the fields from the Parcel struct
Type t = parcel.GetType();

View File

@@ -23,14 +23,14 @@ namespace OpenMetaverse.TestClient
{
StringBuilder sb = new StringBuilder();
string result;
ParcelManager.SimParcelsDownloaded del = delegate(Simulator simulator, InternalDictionary<int, Parcel> simParcels, int[,] parcelMap)
EventHandler<SimParcelsDownloadedEventArgs> del = delegate(object sender, SimParcelsDownloadedEventArgs e)
{
ParcelsDownloaded.Set();
};
ParcelsDownloaded.Reset();
Client.Parcels.OnSimParcelsDownloaded += del;
Client.Parcels.SimParcelsDownloaded += del;
Client.Parcels.RequestAllSimParcels(Client.Network.CurrentSim);
if (Client.Network.CurrentSim.IsParcelMapFull())
@@ -45,16 +45,6 @@ namespace OpenMetaverse.TestClient
{
sb.AppendFormat("Parcel[{0}]: Name: \"{1}\", Description: \"{2}\" ACLBlacklist Count: {3}, ACLWhiteList Count: {5} Traffic: {4}" + System.Environment.NewLine,
parcel.LocalID, parcel.Name, parcel.Desc, parcel.AccessBlackList.Count, parcel.Dwell, parcel.AccessWhiteList.Count);
//foreach (ParcelManager.ParcelAccessEntry white in parcel.AccessWhiteList)
//{
// if(white.AgentID != UUID.Zero)
// sb.AppendFormat("\tAllowed Avatar {0}" + System.Environment.NewLine, white.AgentID);
//}
//foreach (ParcelManager.ParcelAccessEntry black in parcel.AccessBlackList)
//{
// if(black.AgentID != UUID.Zero)
// sb.AppendFormat("\t Banned Avatar {0}" + System.Environment.NewLine, black.AgentID);
//}
});
result = sb.ToString();
@@ -62,7 +52,7 @@ namespace OpenMetaverse.TestClient
else
result = "Failed to retrieve information on all the simulator parcels";
Client.Parcels.OnSimParcelsDownloaded -= del;
Client.Parcels.SimParcelsDownloaded -= del;
return result;
}

View File

@@ -27,23 +27,25 @@ namespace OpenMetaverse.TestClient
if (Int32.TryParse(args[0], out parcelID) && Client.Network.CurrentSim.Parcels.TryGetValue(parcelID, out parcel))
{
AutoResetEvent wait = new AutoResetEvent(false);
ParcelManager.ParcelObjectOwnersListReplyCallback callback = delegate(Simulator simulator, List<ParcelManager.ParcelPrimOwners> primOwners)
EventHandler<ParcelObjectOwnersReplyEventArgs> callback = delegate(object sender, ParcelObjectOwnersReplyEventArgs e)
{
for(int i = 0; i < primOwners.Count; i++)
for (int i = 0; i < e.PrimOwners.Count; i++)
{
result.AppendFormat("Owner: {0} Count: {1}" + System.Environment.NewLine, primOwners[i].OwnerID, primOwners[i].Count);
result.AppendFormat("Owner: {0} Count: {1}" + System.Environment.NewLine, e.PrimOwners[i].OwnerID, e.PrimOwners[i].Count);
wait.Set();
}
};
Client.Parcels.ParcelObjectOwnersReply += callback;
Client.Parcels.OnPrimOwnersListReply += callback;
Client.Parcels.ObjectOwnersRequest(Client.Network.CurrentSim, parcelID);
Client.Parcels.RequestObjectOwners(Client.Network.CurrentSim, parcelID);
if (!wait.WaitOne(10000, false))
{
result.AppendLine("Timed out waiting for packet.");
}
Client.Parcels.OnPrimOwnersListReply -= callback;
Client.Parcels.ParcelObjectOwnersReply -= callback;
return result.ToString();
}

View File

@@ -30,30 +30,31 @@ namespace OpenMetaverse.TestClient
&& UUID.TryParse(args[1], out ownerUUID))
{
AutoResetEvent wait = new AutoResetEvent(false);
ParcelManager.ForceSelectObjects callback = delegate(Simulator simulator, List<uint> objectIDs, bool resetList)
EventHandler<ForceSelectObjectsReplyEventArgs> callback = delegate(object sender, ForceSelectObjectsReplyEventArgs e)
{
//result.AppendLine("New List: " + resetList.ToString());
for(int i = 0; i < objectIDs.Count; i++)
for (int i = 0; i < e.ObjectIDs.Count; i++)
{
result.Append(objectIDs[i].ToString() + " ");
result.Append(e.ObjectIDs[i].ToString() + " ");
counter++;
}
//result.AppendLine("Got " + objectIDs.Count.ToString() + " Objects in packet");
if(objectIDs.Count < 251)
if (e.ObjectIDs.Count < 251)
wait.Set();
};
Client.Parcels.OnParcelSelectedObjects += callback;
Client.Parcels.SelectObjects(parcelID, (ObjectReturnType)16, ownerUUID);
Client.Parcels.ObjectOwnersRequest(Client.Network.CurrentSim, parcelID);
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.OnParcelSelectedObjects -= callback;
Client.Parcels.ForceSelectObjectsReply -= callback;
result.AppendLine("Found a total of " + counter + " Objects");
return result.ToString();
}