Initial commit

I wish I could figure out how to have PlexVie be out of the LibOMV tree but its just not working die to a DLL not found exception about libopenjpeg. (Yes the dll is in the bin folder)
This will do for now
This commit is contained in:
Blake Bourque
2015-06-18 22:15:24 -04:00
commit 0bb2dff347
382 changed files with 273704 additions and 0 deletions
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class AtCommand : Command
{
public AtCommand(TestClient testClient)
{
Name = "@";
Description = "Restrict the following commands to one or all avatars. Usage: @ [firstname lastname]";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID fromAgentID)
{
// This is a dummy command. Calls to it should be intercepted and handled specially
return "This command should not be executed directly";
}
}
}
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class DebugCommand : Command
{
public DebugCommand(TestClient testClient)
{
Name = "debug";
Description = "Turn debug messages on or off. Usage: debug [level] where level is one of None, Debug, Error, Info, Warn";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length != 1)
return "Usage: debug [level] where level is one of None, Debug, Error, Info, Warn";
if (args[0].ToLower() == "debug")
{
Settings.LOG_LEVEL = Helpers.LogLevel.Debug;
return "Logging is set to Debug";
}
else if (args[0].ToLower() == "none")
{
Settings.LOG_LEVEL = Helpers.LogLevel.None;
return "Logging is set to None";
}
else if (args[0].ToLower() == "warn")
{
Settings.LOG_LEVEL = Helpers.LogLevel.Warning;
return "Logging is set to level Warning";
}
else if (args[0].ToLower() == "info")
{
Settings.LOG_LEVEL = Helpers.LogLevel.Info;
return "Logging is set to level Info";
}
else if (args[0].ToLower() == "error")
{
Settings.LOG_LEVEL = Helpers.LogLevel.Error;
return "Logging is set to level Error";
}
else
{
return "Usage: debug [level] where level is one of None, Debug, Error, Info, Warn";
}
}
}
}
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class HelpCommand: Command
{
public HelpCommand(TestClient testClient)
{
Name = "help";
Description = "Lists available commands. usage: help [command] to display information on commands";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length > 0)
{
if (Client.Commands.ContainsKey(args[0]))
return Client.Commands[args[0]].Description;
else
return "Command " + args[0] + " Does not exist. \"help\" to display all available commands.";
}
StringBuilder result = new StringBuilder();
SortedDictionary<CommandCategory, List<Command>> CommandTree = new SortedDictionary<CommandCategory, List<Command>>();
CommandCategory cc;
foreach (Command c in Client.Commands.Values)
{
if (c.Category.Equals(null))
cc = CommandCategory.Unknown;
else
cc = c.Category;
if (CommandTree.ContainsKey(cc))
CommandTree[cc].Add(c);
else
{
List<Command> l = new List<Command>();
l.Add(c);
CommandTree.Add(cc, l);
}
}
foreach (KeyValuePair<CommandCategory, List<Command>> kvp in CommandTree)
{
result.AppendFormat(System.Environment.NewLine + "* {0} Related Commands:" + System.Environment.NewLine, kvp.Key.ToString());
int colMax = 0;
for (int i = 0; i < kvp.Value.Count; i++)
{
if (colMax >= 120)
{
result.AppendLine();
colMax = 0;
}
result.AppendFormat(" {0,-15}", kvp.Value[i].Name);
colMax += 15;
}
result.AppendLine();
}
result.AppendLine(System.Environment.NewLine + "Help [command] for usage/information");
return result.ToString();
}
}
}
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class LoadCommand: Command
{
public LoadCommand(TestClient testClient)
{
Name = "load";
Description = "Loads commands from a dll. (Usage: load AssemblyNameWithoutExtension)";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID 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.";
}
}
}
@@ -0,0 +1,100 @@
using System;
using System.IO;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class PacketLogCommand : Command
{
private TestClient m_client;
private bool m_isLogging;
private int m_packetsToLogRemaining;
private StreamWriter m_logStreamWriter;
public PacketLogCommand(TestClient testClient)
{
Name = "logpacket";
Description = "Logs a given number of packets to a file. For example, packetlog 10 tenpackets.xml";
Category = CommandCategory.TestClient;
m_client = testClient;
}
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length != 2)
return string.Format("Usage: {0} no-of-packets filename", Name);
string rawNumberOfPackets = args[0];
string path = args[1];
int numberOfPackets;
if (!int.TryParse(args[0], out numberOfPackets) || numberOfPackets <= 0)
return string.Format(
"{0} is not a valid number of packets for {1}", rawNumberOfPackets, m_client.Self.Name);
lock (this)
{
if (m_isLogging)
return string.Format(
"Still waiting to finish logging {0} packets for {1}",
m_packetsToLogRemaining, m_client.Self.Name);
try
{
m_logStreamWriter = new StreamWriter(path);
}
catch (Exception e)
{
return string.Format("Could not open file with path [{0}], exception {1}", path, e);
}
m_isLogging = true;
}
m_packetsToLogRemaining = numberOfPackets;
m_client.Network.RegisterCallback(PacketType.Default, HandlePacket);
return string.Format("Now logging {0} packets for {1}", m_packetsToLogRemaining, m_client.Self.Name);
}
/// <summary>
/// Logs the packet received for this client.
/// </summary>
/// <remarks>
/// This handler assumes that packets are processed one at a time.
/// </remarks>
/// <param name="sender">Sender.</param>
/// <param name="args">Arguments.</param>
private void HandlePacket(object sender, PacketReceivedEventArgs args)
{
// Console.WriteLine(
// "Received packet {0} from {1} for {2}", args.Packet.Type, args.Simulator.Name, m_client.Self.Name);
lock (this)
{
if (!m_isLogging)
return;
m_logStreamWriter.WriteLine("Received: {0}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff"));
try
{
m_logStreamWriter.WriteLine(PacketDecoder.PacketToString(args.Packet));
}
catch (Exception e)
{
m_logStreamWriter.WriteLine("Failed to write decode of {0}, exception {1}", args.Packet.Type, e);
}
if (--m_packetsToLogRemaining <= 0)
{
m_client.Network.UnregisterCallback(PacketType.Default, HandlePacket);
m_logStreamWriter.Close();
Console.WriteLine("Finished logging packets for {0}", m_client.Self.Name);
m_isLogging = false;
}
}
}
}
}
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class LoginCommand : Command
{
public LoginCommand(TestClient testClient)
{
Name = "login";
Description = "Logs in another avatar. Usage: login firstname lastname password [simname] [loginuri]";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID fromAgentID)
{
// This is a dummy command. Calls to it should be intercepted and handled specially
return "This command should not be executed directly";
}
}
}
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class LogoutCommand : Command
{
public LogoutCommand(TestClient testClient)
{
Name = "logout";
Description = "Log this avatar out";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID fromAgentID)
{
string name = Client.ToString();
Client.ClientManager.Logout(Client);
return "Logged " + name + " out";
}
}
}
@@ -0,0 +1,23 @@
using System;
using OpenMetaverse;
namespace OpenMetaverse.TestClient
{
public class MD5Command : Command
{
public MD5Command(TestClient testClient)
{
Name = "md5";
Description = "Creates an MD5 hash from a given password. Usage: md5 [password]";
Category = CommandCategory.Other;
}
public override string Execute(string[] args, UUID fromAgentID)
{
if (args.Length == 1)
return Utils.MD5(args[0]);
else
return "Usage: md5 [password]";
}
}
}
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class QuitCommand: Command
{
public QuitCommand(TestClient testClient)
{
Name = "quit";
Description = "Log all avatars out and shut down";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID fromAgentID)
{
// This is a dummy command. Calls to it should be intercepted and handled specially
return "This command should not be executed directly";
}
}
}
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class SetMasterCommand: Command
{
public DateTime Created = DateTime.Now;
private UUID resolvedMasterKey = UUID.Zero;
private ManualResetEvent keyResolution = new ManualResetEvent(false);
private UUID query = UUID.Zero;
public SetMasterCommand(TestClient testClient)
{
Name = "setmaster";
Description = "Sets the user name of the master user. The master user can IM to run commands. Usage: setmaster [name]";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID 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]";
EventHandler<DirPeopleReplyEventArgs> callback = KeyResolvHandler;
Client.Directory.DirPeopleReply += callback;
query = Client.Directory.StartPeopleSearch(masterName, 0);
if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false))
{
Client.MasterKey = resolvedMasterKey;
keyResolution.Reset();
Client.Directory.DirPeopleReply -= callback;
}
else
{
keyResolution.Reset();
Client.Directory.DirPeopleReply -= callback;
return "Unable to obtain UUID for \"" + masterName + "\". Master unchanged.";
}
// Send an Online-only IM to the new master
Client.Self.InstantMessage(
Client.MasterKey, "You are now my master. IM me with \"help\" for a command list.");
return String.Format("Master set to {0} ({1})", masterName, Client.MasterKey.ToString());
}
private void KeyResolvHandler(object sender, DirPeopleReplyEventArgs e)
{
if (query != e.QueryID)
return;
resolvedMasterKey = e.MatchedPeople[0].AgentID;
keyResolution.Set();
query = UUID.Zero;
}
}
}
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.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.";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID fromAgentID)
{
Client.MasterKey = UUID.Parse(args[0]);
lock (Client.Network.Simulators)
{
for (int i = 0; i < Client.Network.Simulators.Count; i++)
{
Avatar master = Client.Network.Simulators[i].ObjectsAvatars.Find(
delegate(Avatar avatar)
{
return avatar.ID == Client.MasterKey;
}
);
if (master != null)
{
Client.Self.InstantMessage(master.ID,
"You are now my master. IM me with \"help\" for a command list.");
break;
}
}
}
return "Master set to " + Client.MasterKey.ToString();
}
}
}
@@ -0,0 +1,75 @@
using System;
using OpenMetaverse;
namespace OpenMetaverse.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]";
Category = CommandCategory.Other;
testClient.Avatars.ViewerEffect += new EventHandler<ViewerEffectEventArgs>(Avatars_ViewerEffect);
testClient.Avatars.ViewerEffectPointAt += new EventHandler<ViewerEffectPointAtEventArgs>(Avatars_ViewerEffectPointAt);
testClient.Avatars.ViewerEffectLookAt += new EventHandler<ViewerEffectLookAtEventArgs>(Avatars_ViewerEffectLookAt);
}
void Avatars_ViewerEffectLookAt(object sender, ViewerEffectLookAtEventArgs e)
{
if (ShowEffects)
Console.WriteLine(
"ViewerEffect [LookAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}",
e.SourceID.ToString(), e.TargetID.ToString(), e.TargetPosition, e.LookType, e.Duration,
e.EffectID.ToString());
}
void Avatars_ViewerEffectPointAt(object sender, ViewerEffectPointAtEventArgs e)
{
if (ShowEffects)
Console.WriteLine(
"ViewerEffect [PointAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}",
e.SourceID.ToString(), e.TargetID.ToString(), e.TargetPosition, e.PointType, e.Duration,
e.EffectID.ToString());
}
void Avatars_ViewerEffect(object sender, ViewerEffectEventArgs e)
{
if (ShowEffects)
Console.WriteLine(
"ViewerEffect [{0}]: SourceID: {1} TargetID: {2} TargetPos: {3} Duration: {4} ID: {5}",
e.Type, e.SourceID.ToString(), e.TargetID.ToString(), e.TargetPosition, e.Duration,
e.EffectID.ToString());
}
public override string Execute(string[] args, UUID 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]";
}
}
}
}
@@ -0,0 +1,44 @@
using System;
using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenMetaverse.TestClient
{
public class SleepCommand : Command
{
uint sleepSerialNum = 1;
public SleepCommand(TestClient testClient)
{
Name = "sleep";
Description = "Uses AgentPause/AgentResume and sleeps for a given number of seconds. Usage: sleep [seconds]";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID fromAgentID)
{
int seconds;
if (args.Length != 1 || !Int32.TryParse(args[0], out seconds))
return "Usage: sleep [seconds]";
AgentPausePacket pause = new AgentPausePacket();
pause.AgentData.AgentID = Client.Self.AgentID;
pause.AgentData.SessionID = Client.Self.SessionID;
pause.AgentData.SerialNum = sleepSerialNum++;
Client.Network.SendPacket(pause);
// Sleep
System.Threading.Thread.Sleep(seconds * 1000);
AgentResumePacket resume = new AgentResumePacket();
resume.AgentData.AgentID = Client.Self.AgentID;
resume.AgentData.SessionID = Client.Self.SessionID;
resume.AgentData.SerialNum = pause.AgentData.SerialNum;
Client.Network.SendPacket(resume);
return "Paused, slept for " + seconds + " second(s), and resumed";
}
}
}
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
namespace OpenMetaverse.TestClient
{
public class WaitForLoginCommand : Command
{
public WaitForLoginCommand(TestClient testClient)
{
Name = "waitforlogin";
Description = "Waits until all bots that are currently attempting to login have succeeded or failed";
Category = CommandCategory.TestClient;
}
public override string Execute(string[] args, UUID fromAgentID)
{
while (ClientManager.Instance.PendingLogins > 0)
{
System.Threading.Thread.Sleep(1000);
Logger.Log("Pending logins: " + ClientManager.Instance.PendingLogins, Helpers.LogLevel.Info);
}
return "All pending logins have completed, currently tracking " + ClientManager.Instance.Clients.Count + " bots";
}
}
}