From bbab7b6b4d1053d62037e7e05c37f9cb607db4da Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Nov 2011 21:22:54 +0000 Subject: Use IsConnected status to determine whether all pCampBots have disconnected, rather than maintaining a separate count Checking IsConnected is more reliable. --- OpenSim/Tools/pCampBot/BotManager.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Tools/pCampBot/BotManager.cs') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 704770a..c4c6f8f 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -51,7 +51,6 @@ namespace pCampBot protected CommandConsole m_console; protected List m_lBot; protected Random somthing = new Random(Environment.TickCount); - protected int numbots = 0; public IConfig Config { get; private set; } /// @@ -200,16 +199,17 @@ namespace pCampBot { case EventType.CONNECTED: m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected"); - numbots++; -// m_log.InfoFormat("NUMBOTS {0}", numbots); break; case EventType.DISCONNECTED: m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected"); - numbots--; -// m_log.InfoFormat("NUMBOTS {0}", numbots); - if (numbots <= 0) - Environment.Exit(0); - break; + + lock (m_lBot) + { + if (m_lBot.TrueForAll(b => !b.IsConnected)) + Environment.Exit(0); + + break; + } } } -- cgit v1.1 From f31a58bd999db3d333da42c4fb15e35e989d9717 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 10 Nov 2011 19:40:45 +0000 Subject: Remove unused index parameter from BotManager.startupBot(). Rename startupBot() => StartBot() --- OpenSim/Tools/pCampBot/BotManager.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'OpenSim/Tools/pCampBot/BotManager.cs') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index c4c6f8f..c77e144 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -136,7 +136,7 @@ namespace pCampBot if (behaviourSwitches.Contains("g")) behaviours.Add(new GrabbingBehaviour()); - startupBot(i, this, behaviours, firstName, lastName, password, loginUri); + StartBot(this, behaviours, firstName, lastName, password, loginUri); } } @@ -156,22 +156,21 @@ namespace pCampBot // int newlen = len + botcount; // for (int i = len; i < newlen; i++) // { -// startupBot(i, Config); +// startupBot(Config); // } // } /// /// This starts up the bot and stores the thread for the bot in the thread array /// - /// The position in the thread array to stick the bot's thread /// /// Behaviours for this bot to perform. /// First name /// Last name /// Password /// Login URI - public void startupBot( - int pos, BotManager bm, List behaviours, + public void StartBot( + BotManager bm, List behaviours, string firstName, string lastName, string password, string loginUri) { Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri); -- cgit v1.1 From 9cba179dff66f7def8f68334893c6db9a65a613e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 10 Nov 2011 20:03:36 +0000 Subject: launch pCampbot shutdown console comand asynchronously --- OpenSim/Tools/pCampBot/BotManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Tools/pCampBot/BotManager.cs') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index c77e144..f5dd5e0 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -233,8 +233,11 @@ namespace pCampBot private void HandleShutdown(string module, string[] cmd) { - m_log.Warn("[BOTMANAGER]: Shutting down bots"); - doBotShutdown(); + Util.FireAndForget(o => + { + m_log.Warn("[BOTMANAGER]: Shutting down bots"); + doBotShutdown(); + }); } private void HandleShowStatus(string module, string[] cmd) -- cgit v1.1