diff --git a/Programs/examples/TestClient/ClientManager.cs b/Programs/examples/TestClient/ClientManager.cs
index 00e44c63..36a076bd 100644
--- a/Programs/examples/TestClient/ClientManager.cs
+++ b/Programs/examples/TestClient/ClientManager.cs
@@ -48,6 +48,7 @@ namespace OpenMetaverse.TestClient
public bool Running = true;
public bool GetTextures = false;
+ public volatile int PendingLogins = 0;
ClientManager()
{
@@ -63,7 +64,6 @@ namespace OpenMetaverse.TestClient
public TestClient Login(string[] args)
{
-
if (args.Length < 3)
{
Console.WriteLine("Usage: login firstname lastname password [simname] [login server url]");
@@ -112,11 +112,6 @@ namespace OpenMetaverse.TestClient
return Login(account);
}
- ///
- ///
- ///
- ///
- ///
public TestClient Login(LoginDetails account)
{
// Check if this client is already logged in
@@ -129,6 +124,8 @@ namespace OpenMetaverse.TestClient
}
}
+ ++PendingLogins;
+
TestClient client = new TestClient(this);
client.Network.OnLogin +=
delegate(LoginStatus login, string message)
@@ -164,11 +161,13 @@ namespace OpenMetaverse.TestClient
}
Logger.Log("Logged in " + client.ToString(), Helpers.LogLevel.Info);
+ --PendingLogins;
}
else if (login == LoginStatus.Failed)
{
Logger.Log("Failed to login " + account.FirstName + " " + account.LastName + ": " +
client.Network.LoginMessage, Helpers.LogLevel.Warning);
+ --PendingLogins;
}
};
@@ -283,6 +282,19 @@ namespace OpenMetaverse.TestClient
ScriptCommand command = new ScriptCommand(null);
Logger.Log(command.Execute(args, UUID.Zero), Helpers.LogLevel.Info);
}
+ else if (firstToken == "waitforlogin")
+ {
+ // Special exception to allow this to run before any bots have logged in
+ if (ClientManager.Instance.PendingLogins > 0)
+ {
+ WaitForLoginCommand command = new WaitForLoginCommand(null);
+ Logger.Log(command.Execute(args, UUID.Zero), Helpers.LogLevel.Info);
+ }
+ else
+ {
+ Logger.Log("No pending logins", Helpers.LogLevel.Info);
+ }
+ }
else
{
// Make an immutable copy of the Clients dictionary to safely iterate over
diff --git a/Programs/examples/TestClient/Commands/System/WaitForLoginCommand.cs b/Programs/examples/TestClient/Commands/System/WaitForLoginCommand.cs
new file mode 100644
index 00000000..d33c4b00
--- /dev/null
+++ b/Programs/examples/TestClient/Commands/System/WaitForLoginCommand.cs
@@ -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";
+ }
+ }
+}