From e93869c7a785a4f375685ffa33c913033ed1c85a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 21 Jun 2007 17:08:21 +0000 Subject: * Importing Ming's mass test client --- .../Commands/System/DebugCommand.cs | 37 ++++++++++ .../Commands/System/HelpCommand.cs | 29 ++++++++ .../Commands/System/LoadCommand.cs | 28 ++++++++ .../Commands/System/LoginCommand.cs | 34 +++++++++ .../Commands/System/LogoutCommand.cs | 24 +++++++ .../mass test client/Commands/System/MD5Command.cs | 22 ++++++ .../Commands/System/PacketLogCommand.cs | 84 ++++++++++++++++++++++ .../Commands/System/QuitCommand.cs | 24 +++++++ .../Commands/System/SetMasterCommand.cs | 73 +++++++++++++++++++ .../Commands/System/SetMasterKeyCommand.cs | 35 +++++++++ .../Commands/System/ShowEffectsCommand.cs | 76 ++++++++++++++++++++ 11 files changed, 466 insertions(+) create mode 100644 tools/mass test client/Commands/System/DebugCommand.cs create mode 100644 tools/mass test client/Commands/System/HelpCommand.cs create mode 100644 tools/mass test client/Commands/System/LoadCommand.cs create mode 100644 tools/mass test client/Commands/System/LoginCommand.cs create mode 100644 tools/mass test client/Commands/System/LogoutCommand.cs create mode 100644 tools/mass test client/Commands/System/MD5Command.cs create mode 100644 tools/mass test client/Commands/System/PacketLogCommand.cs create mode 100644 tools/mass test client/Commands/System/QuitCommand.cs create mode 100644 tools/mass test client/Commands/System/SetMasterCommand.cs create mode 100644 tools/mass test client/Commands/System/SetMasterKeyCommand.cs create mode 100644 tools/mass test client/Commands/System/ShowEffectsCommand.cs (limited to 'tools/mass test client/Commands/System') diff --git a/tools/mass test client/Commands/System/DebugCommand.cs b/tools/mass test client/Commands/System/DebugCommand.cs new file mode 100644 index 0000000..07e2a6c --- /dev/null +++ b/tools/mass test client/Commands/System/DebugCommand.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class DebugCommand : Command + { + public DebugCommand(TestClient testClient) + { + Name = "debug"; + Description = "Turn debug messages on or off. Usage: debug [on/off]"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length != 1) + return "Usage: debug [on/off]"; + + if (args[0].ToLower() == "on") + { + Client.Settings.DEBUG = true; + return "Debug logging is on"; + } + else if (args[0].ToLower() == "off") + { + Client.Settings.DEBUG = false; + return "Debug logging is off"; + } + else + { + return "Usage: debug [on/off]"; + } + } + } +} diff --git a/tools/mass test client/Commands/System/HelpCommand.cs b/tools/mass test client/Commands/System/HelpCommand.cs new file mode 100644 index 0000000..a53b3c0 --- /dev/null +++ b/tools/mass test client/Commands/System/HelpCommand.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class HelpCommand: Command + { + public HelpCommand(TestClient testClient) + { + Name = "help"; + Description = "Lists available commands."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + StringBuilder result = new StringBuilder(); + result.AppendFormat("\n\nHELP\nClient accept teleport lures from master and group members.\n"); + foreach (Command c in Client.Commands.Values) + { + result.AppendFormat(" * {0} - {1}\n", c.Name, c.Description); + } + + return result.ToString(); + } + } +} diff --git a/tools/mass test client/Commands/System/LoadCommand.cs b/tools/mass test client/Commands/System/LoadCommand.cs new file mode 100644 index 0000000..24d2219 --- /dev/null +++ b/tools/mass test client/Commands/System/LoadCommand.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Reflection; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class LoadCommand: Command + { + public LoadCommand(TestClient testClient) + { + Name = "load"; + Description = "Loads commands from a dll. (Usage: load AssemblyNameWithoutExtension)"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length < 1) + return "Usage: load AssemblyNameWithoutExtension"; + + string filename = AppDomain.CurrentDomain.BaseDirectory + args[0] + ".dll"; + Client.RegisterAllCommands(Assembly.LoadFile(filename)); + return "Assembly " + filename + " loaded."; + } + } +} diff --git a/tools/mass test client/Commands/System/LoginCommand.cs b/tools/mass test client/Commands/System/LoginCommand.cs new file mode 100644 index 0000000..6cfc155 --- /dev/null +++ b/tools/mass test client/Commands/System/LoginCommand.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class LoginCommand : Command + { + public LoginCommand(TestClient testClient) + { + Name = "login"; + Description = "Logs in another avatar"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length != 3 && args.Length != 4) + return "usage: login firstname lastname password [simname]"; + + SecondLife newClient = Client.ClientManager.Login(args); + + if (newClient.Network.Connected) + { + return "Logged in " + newClient.ToString(); + } + else + { + return "Failed to login: " + newClient.Network.LoginMessage; + } + } + } +} diff --git a/tools/mass test client/Commands/System/LogoutCommand.cs b/tools/mass test client/Commands/System/LogoutCommand.cs new file mode 100644 index 0000000..8241626 --- /dev/null +++ b/tools/mass test client/Commands/System/LogoutCommand.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class LogoutCommand : Command + { + public LogoutCommand(TestClient testClient) + { + Name = "logout"; + Description = "Log this avatar out"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + string name = Client.ToString(); + Client.ClientManager.Logout(Client); + return "Logged " + name + " out"; + } + } +} diff --git a/tools/mass test client/Commands/System/MD5Command.cs b/tools/mass test client/Commands/System/MD5Command.cs new file mode 100644 index 0000000..2084e67 --- /dev/null +++ b/tools/mass test client/Commands/System/MD5Command.cs @@ -0,0 +1,22 @@ +using System; +using libsecondlife; + +namespace libsecondlife.TestClient +{ + public class MD5Command : Command + { + public MD5Command(TestClient testClient) + { + Name = "md5"; + Description = "Creates an MD5 hash from a given password. Usage: md5 [password]"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length == 1) + return Helpers.MD5(args[0]); + else + return "Usage: md5 [password]"; + } + } +} diff --git a/tools/mass test client/Commands/System/PacketLogCommand.cs b/tools/mass test client/Commands/System/PacketLogCommand.cs new file mode 100644 index 0000000..694cee1 --- /dev/null +++ b/tools/mass test client/Commands/System/PacketLogCommand.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Xml; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class PacketLogCommand : Command + { + List Packets = new List(); + bool Done = false; + int Count = 0; + int Total = 0; + + public PacketLogCommand(TestClient testClient) + { + Name = "packetlog"; + Description = "Logs a given number of packets to an xml file. Usage: packetlog 10 tenpackets.xml"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length != 2) + return "Usage: packetlog 10 tenpackets.xml"; + + XmlWriter writer; + NetworkManager.PacketCallback callback = new NetworkManager.PacketCallback(OnPacket); + + Packets.Clear(); + Done = false; + Count = 0; + + try + { + Total = Int32.Parse(args[0]); + writer = XmlWriter.Create(args[1]); + + Client.Network.RegisterCallback(PacketType.Default, callback); + } + catch (Exception e) + { + return "Usage: packetlog 10 tenpackets.xml (" + e + ")"; + } + + while (!Done) + { + System.Threading.Thread.Sleep(100); + } + + Client.Network.UnregisterCallback(PacketType.Default, callback); + + try + { + Helpers.PacketListToXml(Packets, writer); + } + catch (Exception e) + { + return "Serialization failed: " + e.ToString(); + } + + writer.Close(); + Packets.Clear(); + + return "Exported " + Count + " packets to " + args[1]; + } + + private void OnPacket(Packet packet, Simulator simulator) + { + lock (Packets) + { + if (Count >= Total) + { + Done = true; + } + else + { + Packets.Add(packet); + Count++; + } + } + } + } +} diff --git a/tools/mass test client/Commands/System/QuitCommand.cs b/tools/mass test client/Commands/System/QuitCommand.cs new file mode 100644 index 0000000..2cf0418 --- /dev/null +++ b/tools/mass test client/Commands/System/QuitCommand.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class QuitCommand: Command + { + public QuitCommand(TestClient testClient) + { + Name = "quit"; + Description = "Log all avatars out and shut down"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + Client.ClientManager.LogoutAll(); + Client.ClientManager.Running = false; + return "All avatars logged out"; + } + } +} diff --git a/tools/mass test client/Commands/System/SetMasterCommand.cs b/tools/mass test client/Commands/System/SetMasterCommand.cs new file mode 100644 index 0000000..8601865 --- /dev/null +++ b/tools/mass test client/Commands/System/SetMasterCommand.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class SetMasterCommand: Command + { + public DateTime Created = DateTime.Now; + private LLUUID resolvedMasterKey = LLUUID.Zero; + private ManualResetEvent keyResolution = new ManualResetEvent(false); + private LLUUID query = LLUUID.Zero; + + public SetMasterCommand(TestClient testClient) + { + Name = "setMaster"; + Description = "Sets the user name of the master user. The master user can IM to run commands."; + + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + string masterName = String.Empty; + for (int ct = 0; ct < args.Length;ct++) + masterName = masterName + args[ct] + " "; + masterName = masterName.TrimEnd(); + + if (masterName.Length == 0) + return "Usage setMaster name"; + + DirectoryManager.DirPeopleReplyCallback callback = new DirectoryManager.DirPeopleReplyCallback(KeyResolvHandler); + Client.Directory.OnDirPeopleReply += callback; + query = Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, masterName, 0); + if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false)) + { + Client.MasterKey = resolvedMasterKey; + keyResolution.Reset(); + Client.Directory.OnDirPeopleReply -= callback; + } + else + { + keyResolution.Reset(); + Client.Directory.OnDirPeopleReply -= callback; + return "Unable to obtain UUID for \"" + masterName + "\". Master unchanged."; + } + + + foreach (Avatar av in Client.AvatarList.Values) + { + if (av.ID == Client.MasterKey) + { + Client.Self.InstantMessage(av.ID, "You are now my master. IM me with \"help\" for a command list."); + break; + } + } + + return "Master set to " + masterName + " (" + Client.MasterKey.ToStringHyphenated() + ")"; + } + + private void KeyResolvHandler(LLUUID queryid, List matches) + { + if (query != queryid) + return; + // We can't handle ambiguities here as nicely as we can in ClientManager. + resolvedMasterKey = matches[0].AgentID; + keyResolution.Set(); + query = LLUUID.Zero; + } + } +} diff --git a/tools/mass test client/Commands/System/SetMasterKeyCommand.cs b/tools/mass test client/Commands/System/SetMasterKeyCommand.cs new file mode 100644 index 0000000..1fa6336 --- /dev/null +++ b/tools/mass test client/Commands/System/SetMasterKeyCommand.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class SetMasterKeyCommand : Command + { + public DateTime Created = DateTime.Now; + + public SetMasterKeyCommand(TestClient testClient) + { + Name = "setMasterKey"; + Description = "Sets the key of the master user. The master user can IM to run commands."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + Client.MasterKey = LLUUID.Parse(args[0]); + + foreach (Avatar av in Client.AvatarList.Values) + { + if (av.ID == Client.MasterKey) + { + Client.Self.InstantMessage(av.ID, "You are now my master. IM me with \"help\" for a command list."); + break; + } + } + + return "Master set to " + Client.MasterKey; + } + } +} diff --git a/tools/mass test client/Commands/System/ShowEffectsCommand.cs b/tools/mass test client/Commands/System/ShowEffectsCommand.cs new file mode 100644 index 0000000..4d46e35 --- /dev/null +++ b/tools/mass test client/Commands/System/ShowEffectsCommand.cs @@ -0,0 +1,76 @@ +using System; +using libsecondlife; + +namespace libsecondlife.TestClient +{ + public class ShowEffectsCommand : Command + { + bool ShowEffects = false; + + public ShowEffectsCommand(TestClient testClient) + { + Name = "showeffects"; + Description = "Prints out information for every viewer effect that is received. Usage: showeffects [on/off]"; + + testClient.Avatars.OnEffect += new AvatarManager.EffectCallback(Avatars_OnEffect); + testClient.Avatars.OnLookAt += new AvatarManager.LookAtCallback(Avatars_OnLookAt); + testClient.Avatars.OnPointAt += new AvatarManager.PointAtCallback(Avatars_OnPointAt); + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length == 0) + { + ShowEffects = true; + return "Viewer effects will be shown on the console"; + } + else if (args.Length == 1) + { + if (args[0] == "on") + { + ShowEffects = true; + return "Viewer effects will be shown on the console"; + } + else + { + ShowEffects = false; + return "Viewer effects will not be shown"; + } + } + else + { + return "Usage: showeffects [on/off]"; + } + } + + private void Avatars_OnPointAt(LLUUID sourceID, LLUUID targetID, LLVector3d targetPos, + MainAvatar.PointAtType pointType, float duration, LLUUID id) + { + if (ShowEffects) + Console.WriteLine( + "ViewerEffect [PointAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}", + sourceID.ToStringHyphenated(), targetID.ToStringHyphenated(), targetPos, pointType, duration, + id.ToStringHyphenated()); + } + + private void Avatars_OnLookAt(LLUUID sourceID, LLUUID targetID, LLVector3d targetPos, + MainAvatar.LookAtType lookType, float duration, LLUUID id) + { + if (ShowEffects) + Console.WriteLine( + "ViewerEffect [LookAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}", + sourceID.ToStringHyphenated(), targetID.ToStringHyphenated(), targetPos, lookType, duration, + id.ToStringHyphenated()); + } + + private void Avatars_OnEffect(MainAvatar.EffectType type, LLUUID sourceID, LLUUID targetID, + LLVector3d targetPos, float duration, LLUUID id) + { + if (ShowEffects) + Console.WriteLine( + "ViewerEffect [{0}]: SourceID: {1} TargetID: {2} TargetPos: {3} Duration: {4} ID: {5}", + type, sourceID.ToStringHyphenated(), targetID.ToStringHyphenated(), targetPos, duration, + id.ToStringHyphenated()); + } + } +} -- cgit v1.1