public TestClient Login(LoginDetails account, bool use3DiLogin)
{
// Check if this client is already logged in
foreach (TestClient c in Clients.Values)
{
if (c.Self.FirstName == account.FirstName && c.Self.LastName == account.LastName)
{
Logout(c);
break;
}
}
TestClient client = new TestClient(this);
// Optimize the throttle
client.Throttle.Wind = 0;
client.Throttle.Cloud = 0;
client.Throttle.Land = 1000000;
client.Throttle.Task = 1000000;
client.GroupCommands = account.GroupCommands;
client.MasterName = account.MasterName;
client.MasterKey = account.MasterKey;
client.AllowObjectMaster = client.MasterKey != UUID.Zero; // Require UUID for object master.
LoginParams loginParams = client.Network.DefaultLoginParams(
account.FirstName, account.LastName, account.Password, "TestClient", version);
if (!String.IsNullOrEmpty(account.StartLocation))
loginParams.Start = account.StartLocation;
if (!String.IsNullOrEmpty(account.URI))
loginParams.URI = account.URI;
bool loginStatus;
if (use3DiLogin == true)
{
loginStatus = client.Network.Login3Di(loginParams);
}
else
{
loginStatus = client.Network.Login(loginParams);
}
if (loginStatus)
{
Clients[client.Self.AgentID] = client;
if (client.MasterKey == UUID.Zero)
{
UUID query = UUID.Random();
DirectoryManager.DirPeopleReplyCallback peopleDirCallback =
delegate(UUID queryID, List<DirectoryManager.AgentSearchData> matchedPeople)
{
if (queryID == query)
{
if (matchedPeople.Count != 1)
{
Logger.Log("Unable to resolve master key from " + client.MasterName, Helpers.LogLevel.Warning);
}
else
{
client.MasterKey = matchedPeople[0].AgentID;
Logger.Log("Master key resolved to " + client.MasterKey, Helpers.LogLevel.Info);
}
}
};
client.Directory.OnDirPeopleReply += peopleDirCallback;
client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, client.MasterName, 0, query);
}
Logger.Log("Logged in " + client.ToString(), Helpers.LogLevel.Info);
}
else
{
Logger.Log("Failed to login " + account.FirstName + " " + account.LastName + ": " +
client.Network.LoginMessage, Helpers.LogLevel.Warning);
}
return client;
}