2007-01-27 08:23:17 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using CommandLine.Utility;
|
|
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2007-01-27 08:23:17 +00:00
|
|
|
{
|
2007-06-04 23:40:57 +00:00
|
|
|
public class CommandLineArgumentsException : Exception
|
|
|
|
|
{
|
|
|
|
|
}
|
2008-10-08 20:21:32 +00:00
|
|
|
|
2007-01-27 08:23:17 +00:00
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
private static void Usage()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Usage: " + Environment.NewLine +
|
2008-10-09 18:04:06 +00:00
|
|
|
"TestClient.exe --first firstname --last lastname --pass password [--loginuri=\"uri\"] [--startpos \"sim/x/y/z\"] [--master \"master name\"] [--masterkey \"master uuid\"] [--gettextures]");
|
2007-01-27 08:23:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
Arguments arguments = new Arguments(args);
|
|
|
|
|
|
|
|
|
|
ClientManager manager;
|
|
|
|
|
List<LoginDetails> accounts = new List<LoginDetails>();
|
|
|
|
|
LoginDetails account;
|
2008-02-07 17:32:06 +00:00
|
|
|
bool groupCommands = false;
|
2007-04-23 01:39:14 +00:00
|
|
|
string masterName = String.Empty;
|
2008-07-25 05:15:05 +00:00
|
|
|
UUID masterKey = UUID.Zero;
|
2007-04-01 12:31:25 +00:00
|
|
|
string file = String.Empty;
|
2008-10-08 20:21:32 +00:00
|
|
|
string loginuri = String.Empty;
|
2008-10-09 18:04:06 +00:00
|
|
|
bool getTextures = false;
|
2007-01-27 08:23:17 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (arguments["groupcommands"] != null)
|
|
|
|
|
groupCommands = true;
|
2008-02-07 17:32:06 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (arguments["masterkey"] != null)
|
|
|
|
|
masterKey = UUID.Parse(arguments["masterkey"]);
|
2007-01-27 08:23:17 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (arguments["master"] != null)
|
|
|
|
|
masterName = arguments["master"];
|
|
|
|
|
|
|
|
|
|
if (arguments["loginuri"] != null)
|
|
|
|
|
loginuri = arguments["loginuri"];
|
|
|
|
|
|
2008-10-09 18:04:06 +00:00
|
|
|
if (arguments["gettextures"] != null)
|
|
|
|
|
getTextures = true;
|
|
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (arguments["file"] != null)
|
|
|
|
|
{
|
|
|
|
|
file = arguments["file"];
|
2007-06-04 23:40:57 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (!File.Exists(file))
|
2007-11-06 09:26:10 +00:00
|
|
|
{
|
2008-10-08 20:21:32 +00:00
|
|
|
Console.WriteLine("File {0} Does not exist", file);
|
|
|
|
|
return;
|
2007-11-06 09:26:10 +00:00
|
|
|
}
|
2007-06-04 23:40:57 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
// Loading names from a file
|
|
|
|
|
try
|
2007-06-04 23:40:57 +00:00
|
|
|
{
|
2008-10-08 20:21:32 +00:00
|
|
|
using (StreamReader reader = new StreamReader(file))
|
2008-04-22 02:00:53 +00:00
|
|
|
{
|
2008-10-08 20:21:32 +00:00
|
|
|
string line;
|
|
|
|
|
int lineNumber = 0;
|
2008-04-22 02:00:53 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
while ((line = reader.ReadLine()) != null)
|
2007-06-04 23:40:57 +00:00
|
|
|
{
|
2008-10-08 20:21:32 +00:00
|
|
|
lineNumber++;
|
|
|
|
|
string[] tokens = line.Trim().Split(new char[] { ' ', ',' });
|
2007-06-04 23:40:57 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (tokens.Length >= 3)
|
2007-06-04 23:40:57 +00:00
|
|
|
{
|
2008-10-08 20:21:32 +00:00
|
|
|
account = new LoginDetails();
|
|
|
|
|
account.FirstName = tokens[0];
|
|
|
|
|
account.LastName = tokens[1];
|
|
|
|
|
account.Password = tokens[2];
|
|
|
|
|
|
|
|
|
|
accounts.Add(account);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Logger.Log("Invalid data on line " + lineNumber +
|
|
|
|
|
", must be in the format of: FirstName LastName Password",
|
|
|
|
|
Helpers.LogLevel.Warning);
|
2007-06-04 23:40:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-12-05 20:23:46 +00:00
|
|
|
}
|
2008-10-08 20:21:32 +00:00
|
|
|
catch (Exception e)
|
2007-04-23 01:39:14 +00:00
|
|
|
{
|
2008-10-08 20:21:32 +00:00
|
|
|
Console.WriteLine("Error reading from " + args[1]);
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
return;
|
2007-04-23 01:39:14 +00:00
|
|
|
}
|
2007-06-04 23:40:57 +00:00
|
|
|
}
|
2008-10-08 20:21:32 +00:00
|
|
|
else if (arguments["first"] != null && arguments["last"] != null && arguments["pass"] != null)
|
|
|
|
|
{
|
|
|
|
|
// Taking a single login off the command-line
|
|
|
|
|
account = new LoginDetails();
|
|
|
|
|
account.FirstName = arguments["first"];
|
|
|
|
|
account.LastName = arguments["last"];
|
|
|
|
|
account.Password = arguments["pass"];
|
2007-06-04 23:40:57 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
accounts.Add(account);
|
|
|
|
|
}
|
|
|
|
|
else if (arguments["help"] != null)
|
2007-06-04 23:40:57 +00:00
|
|
|
{
|
|
|
|
|
Usage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (LoginDetails a in accounts)
|
|
|
|
|
{
|
2008-02-07 17:32:06 +00:00
|
|
|
a.GroupCommands = groupCommands;
|
2007-06-04 23:40:57 +00:00
|
|
|
a.MasterName = masterName;
|
|
|
|
|
a.MasterKey = masterKey;
|
2007-11-06 09:26:10 +00:00
|
|
|
a.URI = loginuri;
|
2007-06-04 23:40:57 +00:00
|
|
|
}
|
2007-01-27 08:23:17 +00:00
|
|
|
|
|
|
|
|
// Login the accounts and run the input loop
|
2007-06-04 23:40:57 +00:00
|
|
|
if (arguments["startpos"] != null)
|
2008-10-09 18:04:06 +00:00
|
|
|
manager = new ClientManager(accounts, arguments["startpos"], getTextures);
|
2007-06-04 23:40:57 +00:00
|
|
|
else
|
2008-10-09 18:04:06 +00:00
|
|
|
manager = new ClientManager(accounts, getTextures);
|
2007-06-04 23:40:57 +00:00
|
|
|
|
|
|
|
|
manager.Run();
|
2007-01-27 08:23:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|