* Fixed a bug in SetAvatarInformation() where the AboutText wasn't being set

* Added FindSimCommand to TestClient that searches for a simulator name and returns the region handle and X/Y coords
* Added CloneProfileCommand to TestClient that demos the avatar profile commands in libsl

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@766 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2006-12-27 21:55:35 +00:00
parent 3892bc7a9d
commit 5dfd504cd4
6 changed files with 155 additions and 6 deletions

View File

@@ -384,6 +384,7 @@ namespace libsecondlife
apup.AgentData.SessionID = Client.Network.SessionID;
apup.PropertiesData = new AvatarPropertiesUpdatePacket.PropertiesDataBlock();
apup.PropertiesData.AboutText = Helpers.StringToField(this.ProfileProperties.AboutText);
apup.PropertiesData.AllowPublish = this.ProfileProperties.AllowPublish;
apup.PropertiesData.FLAboutText = Helpers.StringToField(this.ProfileProperties.FirstLifeText);
apup.PropertiesData.FLImageID = this.ProfileProperties.FirstLifeImage;

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;

View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Threading;
using libsecondlife;
using libsecondlife.Packets;
namespace libsecondlife.TestClient
{
public class CloneProfileCommand : Command
{
SecondLife Client;
Avatar.Properties Properties;
Avatar.Interests Interests;
bool ReceivedProperties = false;
bool ReceivedInterests = false;
ManualResetEvent ReceivedProfileEvent = new ManualResetEvent(false);
public CloneProfileCommand(TestClient testClient)
{
TestClient = testClient;
Client = (SecondLife)TestClient;
Client.Avatars.OnAvatarInterests += new AvatarManager.AvatarInterestsCallback(Avatars_OnAvatarInterests);
Client.Avatars.OnAvatarProperties += new AvatarManager.AvatarPropertiesCallback(Avatars_OnAvatarProperties);
Name = "cloneprofile";
Description = "Clones another avatars profile as closely as possible. WARNING: This command will " +
"destroy your existing profile! Usage: cloneprofile [targetuuid]";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
if (args.Length != 1)
return Description;
LLUUID targetID;
ReceivedProperties = false;
ReceivedInterests = false;
try
{
targetID = new LLUUID(args[0]);
}
catch (Exception)
{
return Description;
}
Client.Avatars.RequestAvatarProperties(targetID);
ReceivedProfileEvent.Reset();
ReceivedProfileEvent.WaitOne(5000, false);
if (!ReceivedInterests || !ReceivedProperties)
return "Failed to retrieve a complete profile for that UUID";
Client.Self.ProfileInterests = Interests;
Client.Self.ProfileProperties = Properties;
Client.Self.SetAvatarInformation();
return "Synchronized our profile to the profile of " + targetID.ToStringHyphenated();
}
void Avatars_OnAvatarProperties(LLUUID avatarID, Avatar.Properties properties)
{
lock (ReceivedProfileEvent)
{
Properties = properties;
ReceivedProperties = true;
if (ReceivedInterests && ReceivedProperties)
ReceivedProfileEvent.Set();
}
}
void Avatars_OnAvatarInterests(LLUUID avatarID, Avatar.Interests interests)
{
lock (ReceivedProfileEvent)
{
Interests = interests;
ReceivedInterests = true;
if (ReceivedInterests && ReceivedProperties)
ReceivedProfileEvent.Set();
}
}
}
}

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
namespace libsecondlife.TestClient
{
public class FindSimCommand : Command
{
SecondLife Client;
Dictionary<SecondLife, bool> GridDataCached = new Dictionary<SecondLife, bool>();
public FindSimCommand(TestClient testClient)
{
TestClient = testClient;
Client = (SecondLife)TestClient;
Name = "findsim";
Description = "Searches for a simulator and returns information about it. Usage: findsim [Simulator Name]";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
if (args.Length < 1)
return "Usage: findsim [Simulator Name]";
string simName = string.Empty;
for (int i = 0; i < args.Length; i++)
simName += args[i] + " ";
simName = simName.TrimEnd().ToLower();
if (!GridDataCached.ContainsKey(Client))
{
GridDataCached[Client] = false;
}
if (!GridDataCached[Client])
{
Client.Grid.AddAllSims();
System.Threading.Thread.Sleep(5000);
GridDataCached[Client] = true;
}
int attempts = 0;
GridRegion region = null;
while (region == null && attempts++ < 5)
{
region = Client.Grid.GetGridRegion(simName);
}
if (region != null)
return "Found " + region.Name + ": handle=" + region.RegionHandle +
"(" + region.X + "," + region.Y + ")";
else
return "Lookup of " + simName + " failed";
}
}
}

View File

@@ -10,6 +10,10 @@ namespace libsecondlife.TestClient
{
public class TestClient : SecondLife
{
public delegate void PrimCreatedCallback(Simulator simulator, PrimObject prim);
public event PrimCreatedCallback OnPrimCreated;
public Dictionary<Simulator, Dictionary<uint, PrimObject>> SimPrims;
public LLUUID GroupID = LLUUID.Zero;
public Dictionary<LLUUID, GroupMember> GroupMembers;
@@ -18,12 +22,9 @@ namespace libsecondlife.TestClient
public Dictionary<string, Command> Commands = new Dictionary<string,Command>();
public Dictionary<string, object> SharedValues = new Dictionary<string, object>();
public bool Running = true;
public string Master = "";
public string Master = String.Empty;
public ClientManager ClientManager;
public delegate void PrimCreatedCallback(Simulator simulator, PrimObject prim);
public event PrimCreatedCallback OnPrimCreated;
private LLQuaternion bodyRotation = LLQuaternion.Identity;
private LLVector3 forward = new LLVector3(0, 0.9999f, 0);
private LLVector3 left = new LLVector3(0.9999f, 0, 0);
@@ -31,7 +32,6 @@ namespace libsecondlife.TestClient
private int DrawDistance = 64;
private System.Timers.Timer updateTimer;
/// <summary>
///
/// </summary>

View File

@@ -37,8 +37,10 @@
<Compile Include="Command.cs" />
<Compile Include="Commands\AppearanceCommand.cs" />
<Compile Include="Commands\BalanceCommand.cs" />
<Compile Include="Commands\CloneProfileCommand.cs" />
<Compile Include="Commands\EchoMasterCommand.cs" />
<Compile Include="Commands\ExportOutfitCommand.cs" />
<Compile Include="Commands\FindSimCommand.cs" />
<Compile Include="Commands\FollowCommand.cs">
<SubType>Code</SubType>
</Compile>