From ea3f024b8a546608fce825d4aa9f165eaecfeed5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Aug 2013 21:25:17 +0100 Subject: refactor: start bot connection thread within BotManager rather than externally --- OpenSim/Tools/pCampBot/BotManager.cs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'OpenSim/Tools/pCampBot/BotManager.cs') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 2cbadef..fe6048a 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -52,6 +52,11 @@ namespace pCampBot public const int DefaultLoginDelay = 5000; /// + /// Is pCampbot in the process of connecting bots? + /// + public bool ConnectingBots { get; private set; } + + /// /// Is pCampbot in the process of disconnecting bots? /// public bool DisconnectingBots { get; private set; } @@ -219,7 +224,25 @@ namespace pCampBot botcount, m_firstName, m_lastNameStem, m_password, m_loginUri, m_startUri, m_fromBotNumber, m_wearSetting, m_behaviourSwitches); } - private void ConnectBots( + private bool ConnectBots( + int botcount, string firstName, string lastNameStem, string password, string loginUri, string startUri, int fromBotNumber, string wearSetting, + HashSet behaviourSwitches) + { + ConnectingBots = true; + + Thread startBotThread + = new Thread( + o => ConnectBotsInternal( + botcount, firstName, lastNameStem, password, loginUri, startUri, fromBotNumber, wearSetting, + behaviourSwitches)); + + startBotThread.Name = "Bots connection thread"; + startBotThread.Start(); + + return true; + } + + private void ConnectBotsInternal( int botcount, string firstName, string lastNameStem, string password, string loginUri, string startUri, int fromBotNumber, string wearSetting, HashSet behaviourSwitches) { @@ -273,6 +296,8 @@ namespace pCampBot // Stagger logins Thread.Sleep(LoginDelay); } + + ConnectingBots = false; } /// -- cgit v1.1