From a90a5f52dd5f053a83a09fdd70ca08148ef641ce Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Aug 2013 19:38:20 +0100 Subject: Show number of connections each bot has established in "show bots" command. --- OpenSim/Tools/pCampBot/Bot.cs | 15 ++++++++++++++- OpenSim/Tools/pCampBot/BotManager.cs | 17 ++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index 32bf32b..be7a5a1 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -97,6 +97,19 @@ namespace pCampBot /// public ConnectionState ConnectionState { get; private set; } + /// + /// The number of connections that this bot has to different simulators. + /// + /// Includes both root and child connections. + public int ConnectionsCount + { + get + { + lock (Client.Network.Simulators) + return Client.Network.Simulators.Count; + } + } + public string FirstName { get; private set; } public string LastName { get; private set; } public string Name { get; private set; } @@ -144,7 +157,7 @@ namespace pCampBot ConnectionState = ConnectionState.Disconnected; behaviours.ForEach(b => b.Initialize(this)); - + Client = new GridClient(); Random = new Random(Environment.TickCount);// We do stuff randomly here diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index dee02c3..8f31bdf 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -395,8 +395,11 @@ namespace pCampBot private void HandleShowStatus(string module, string[] cmd) { - string outputFormat = "{0,-30} {1, -30} {2,-14}"; - MainConsole.Instance.OutputFormat(outputFormat, "Name", "Region", "Status"); + ConsoleDisplayTable cdt = new ConsoleDisplayTable(); + cdt.AddColumn("Name", 30); + cdt.AddColumn("Region", 30); + cdt.AddColumn("Status", 14); + cdt.AddColumn("Connections", 11); Dictionary totals = new Dictionary(); foreach (object o in Enum.GetValues(typeof(ConnectionState))) @@ -409,19 +412,19 @@ namespace pCampBot Simulator currentSim = pb.Client.Network.CurrentSim; totals[pb.ConnectionState]++; - MainConsole.Instance.OutputFormat( - outputFormat, - pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState); + cdt.AddRow( + pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState, pb.ConnectionsCount); } } + MainConsole.Instance.Output(cdt.ToString()); + ConsoleDisplayList cdl = new ConsoleDisplayList(); foreach (KeyValuePair kvp in totals) cdl.AddRow(kvp.Key, kvp.Value); - - MainConsole.Instance.OutputFormat("\n{0}", cdl.ToString()); + MainConsole.Instance.Output(cdl.ToString()); } /* -- cgit v1.1 From 49b7cbda72cdaae8b5a7a89c94915851997b0b13 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Aug 2013 20:29:17 +0100 Subject: Create a separate pCampbot "disconnect" console command which disconnects connected bots. "quit" console command now requires bots to be separate disconnected first before quitting. This is to prepare the way for disconnecting/reconnecting different numbers of bots in a pCampbot session. And hopefully resolves bug where console appears not to be reset if Environment.Exit(0) is called on a different thread --- OpenSim/Tools/pCampBot/BotManager.cs | 110 +++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 43 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 8f31bdf..5c0dc81 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -52,9 +52,9 @@ namespace pCampBot public const int DefaultLoginDelay = 5000; /// - /// True if pCampbot is in the process of shutting down. + /// Is pCampbot in the process of disconnecting bots? /// - public bool ShuttingDown { get; private set; } + public bool DisconnectingBots { get; private set; } /// /// Delay between logins of multiple bots. @@ -139,6 +139,11 @@ namespace pCampBot "Shutdown bots and exit", HandleShutdown); + m_console.Commands.AddCommand("bot", false, "disconnect", + "disconnect", + "Disconnect all bots", + HandleDisconnect); + m_console.Commands.AddCommand("bot", false, "show regions", "show regions", "Show regions known to bots", @@ -191,31 +196,37 @@ namespace pCampBot for (int i = 0; i < botcount; i++) { - if (ShuttingDown) - break; + lock (m_lBot) + { + if (DisconnectingBots) + break; + + string lastName = string.Format("{0}_{1}", lastNameStem, i + fromBotNumber); - string lastName = string.Format("{0}_{1}", lastNameStem, i + fromBotNumber); + // We must give each bot its own list of instantiated behaviours since they store state. + List behaviours = new List(); + + // Hard-coded for now + if (behaviourSwitches.Contains("c")) + behaviours.Add(new CrossBehaviour()); - // We must give each bot its own list of instantiated behaviours since they store state. - List behaviours = new List(); - - // Hard-coded for now - if (behaviourSwitches.Contains("c")) - behaviours.Add(new CrossBehaviour()); + if (behaviourSwitches.Contains("g")) + behaviours.Add(new GrabbingBehaviour()); - if (behaviourSwitches.Contains("g")) - behaviours.Add(new GrabbingBehaviour()); + if (behaviourSwitches.Contains("n")) + behaviours.Add(new NoneBehaviour()); - if (behaviourSwitches.Contains("n")) - behaviours.Add(new NoneBehaviour()); + if (behaviourSwitches.Contains("p")) + behaviours.Add(new PhysicsBehaviour()); + + if (behaviourSwitches.Contains("t")) + behaviours.Add(new TeleportBehaviour()); - if (behaviourSwitches.Contains("p")) - behaviours.Add(new PhysicsBehaviour()); - - if (behaviourSwitches.Contains("t")) - behaviours.Add(new TeleportBehaviour()); + StartBot(this, behaviours, firstName, lastName, password, loginUri, startUri, wearSetting); + } - StartBot(this, behaviours, firstName, lastName, password, loginUri, startUri, wearSetting); + // Stagger logins + Thread.Sleep(LoginDelay); } } @@ -305,17 +316,13 @@ namespace pCampBot pb.OnConnected += handlebotEvent; pb.OnDisconnected += handlebotEvent; - lock (m_lBot) - m_lBot.Add(pb); + m_lBot.Add(pb); Thread pbThread = new Thread(pb.startup); pbThread.Name = pb.Name; pbThread.IsBackground = true; pbThread.Start(); - - // Stagger logins - Thread.Sleep(LoginDelay); } /// @@ -328,18 +335,16 @@ namespace pCampBot switch (eventt) { case EventType.CONNECTED: + { m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected"); break; + } + case EventType.DISCONNECTED: + { m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected"); - - lock (m_lBot) - { - if (m_lBot.TrueForAll(b => b.ConnectionState == ConnectionState.Disconnected)) - Environment.Exit(0); - - break; - } + break; + } } } @@ -349,15 +354,12 @@ namespace pCampBot /// /// We launch each shutdown on its own thread so that a slow shutting down bot doesn't hold up all the others. /// - public void doBotShutdown() + private void ShutdownBots() { - lock (m_lBot) + foreach (Bot bot in m_lBot) { - foreach (Bot bot in m_lBot) - { - Bot thisBot = bot; - Util.FireAndForget(o => thisBot.shutdown()); - } + Bot thisBot = bot; + Util.FireAndForget(o => thisBot.shutdown()); } } @@ -370,12 +372,34 @@ namespace pCampBot return new LocalConsole("pCampbot"); } + private void HandleDisconnect(string module, string[] cmd) + { + MainConsole.Instance.Output("Disconnecting bots"); + + lock (m_lBot) + { + DisconnectingBots = true; + + ShutdownBots(); + } + } + private void HandleShutdown(string module, string[] cmd) { + lock (m_lBot) + { + int connectedBots = m_lBot.Count(b => b.ConnectionState == ConnectionState.Connected); + + if (connectedBots > 0) + { + MainConsole.Instance.OutputFormat("Please disconnect {0} connected bots first", connectedBots); + return; + } + } + MainConsole.Instance.Output("Shutting down"); - ShuttingDown = true; - doBotShutdown(); + Environment.Exit(0); } private void HandleShowRegions(string module, string[] cmd) -- cgit v1.1 From 2fa42f24fd0e80adc16320a404e3e85ca6d1baa1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Aug 2013 21:00:31 +0100 Subject: Make it possible to disconnected a specified number of bots via the pCampbot console command "disconnect []" Bots disconnected are ascending from last in numeric order. Temporarily no way to reconnect bots. --- OpenSim/Tools/pCampBot/BotManager.cs | 101 +++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 46 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 5c0dc81..157c69c 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -80,7 +80,7 @@ namespace pCampBot /// /// Created bots, whether active or inactive. /// - protected List m_lBot; + protected List m_bots; /// /// Random number generator. @@ -130,35 +130,30 @@ namespace pCampBot } } - m_console.Commands.AddCommand("bot", false, "shutdown", - "shutdown", - "Shutdown bots and exit", HandleShutdown); + m_console.Commands.AddCommand( + "bot", false, "shutdown", "shutdown", "Shutdown bots and exit", HandleShutdown); - m_console.Commands.AddCommand("bot", false, "quit", - "quit", - "Shutdown bots and exit", - HandleShutdown); + m_console.Commands.AddCommand( + "bot", false, "quit", "quit", "Shutdown bots and exit", HandleShutdown); - m_console.Commands.AddCommand("bot", false, "disconnect", - "disconnect", - "Disconnect all bots", - HandleDisconnect); + m_console.Commands.AddCommand( + "bot", false, "disconnect", "disconnect []", "Disconnect bots", + "Disconnecting bots will interupt any bot connection process, including connection on startup.\n" + + "If an is given, then the last connected bots by postfix number are disconnected.\n" + + "If no is given, then all currently connected bots are disconnected.", + HandleDisconnect); - m_console.Commands.AddCommand("bot", false, "show regions", - "show regions", - "Show regions known to bots", - HandleShowRegions); + m_console.Commands.AddCommand( + "bot", false, "show regions", "show regions", "Show regions known to bots", HandleShowRegions); - m_console.Commands.AddCommand("bot", false, "show bots", - "show bots", - "Shows the status of all bots", - HandleShowStatus); + m_console.Commands.AddCommand( + "bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowStatus); // m_console.Commands.AddCommand("bot", false, "add bots", // "add bots ", // "Add more bots", HandleAddBots); - m_lBot = new List(); + m_bots = new List(); } /// @@ -196,7 +191,7 @@ namespace pCampBot for (int i = 0; i < botcount; i++) { - lock (m_lBot) + lock (m_bots) { if (DisconnectingBots) break; @@ -316,7 +311,7 @@ namespace pCampBot pb.OnConnected += handlebotEvent; pb.OnDisconnected += handlebotEvent; - m_lBot.Add(pb); + m_bots.Add(pb); Thread pbThread = new Thread(pb.startup); pbThread.Name = pb.Name; @@ -349,21 +344,6 @@ namespace pCampBot } /// - /// Shut down all bots - /// - /// - /// We launch each shutdown on its own thread so that a slow shutting down bot doesn't hold up all the others. - /// - private void ShutdownBots() - { - foreach (Bot bot in m_lBot) - { - Bot thisBot = bot; - Util.FireAndForget(o => thisBot.shutdown()); - } - } - - /// /// Standard CreateConsole routine /// /// @@ -374,21 +354,50 @@ namespace pCampBot private void HandleDisconnect(string module, string[] cmd) { - MainConsole.Instance.Output("Disconnecting bots"); - - lock (m_lBot) + lock (m_bots) { + int botsToDisconnect; + int connectedBots = m_bots.Count(b => b.ConnectionState == ConnectionState.Connected); + + if (cmd.Length == 1) + { + botsToDisconnect = connectedBots; + } + else + { + if (!ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, cmd[1], out botsToDisconnect)) + return; + + botsToDisconnect = Math.Min(botsToDisconnect, connectedBots); + } + DisconnectingBots = true; - ShutdownBots(); + MainConsole.Instance.OutputFormat("Disconnecting {0} bots", botsToDisconnect); + + int disconnectedBots = 0; + + for (int i = m_bots.Count - 1; i >= 0; i--) + { + if (disconnectedBots >= botsToDisconnect) + break; + + Bot thisBot = m_bots[i]; + + if (thisBot.ConnectionState == ConnectionState.Connected) + { + Util.FireAndForget(o => thisBot.shutdown()); + disconnectedBots++; + } + } } } private void HandleShutdown(string module, string[] cmd) { - lock (m_lBot) + lock (m_bots) { - int connectedBots = m_lBot.Count(b => b.ConnectionState == ConnectionState.Connected); + int connectedBots = m_bots.Count(b => b.ConnectionState == ConnectionState.Connected); if (connectedBots > 0) { @@ -429,9 +438,9 @@ namespace pCampBot foreach (object o in Enum.GetValues(typeof(ConnectionState))) totals[(ConnectionState)o] = 0; - lock (m_lBot) + lock (m_bots) { - foreach (Bot pb in m_lBot) + foreach (Bot pb in m_bots) { Simulator currentSim = pb.Client.Network.CurrentSim; totals[pb.ConnectionState]++; -- cgit v1.1 From 079cd4e94f820bad83fcbf8373ef268ecb82d9a6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Aug 2013 21:17:59 +0100 Subject: refactor: restructure pCampbot multi-bot connection code. --- OpenSim/Tools/pCampBot/BotManager.cs | 70 ++++++++++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 10 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 157c69c..2cbadef 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -98,6 +98,46 @@ namespace pCampBot public Dictionary RegionsKnown { get; private set; } /// + /// First name for bots + /// + private string m_firstName; + + /// + /// Last name stem for bots + /// + private string m_lastNameStem; + + /// + /// Password for bots + /// + private string m_password; + + /// + /// Login URI for bots. + /// + private string m_loginUri; + + /// + /// Start location for bots. + /// + private string m_startUri; + + /// + /// Postfix bot number at which bot sequence starts. + /// + private int m_fromBotNumber; + + /// + /// Wear setting for bots. + /// + private string m_wearSetting; + + /// + /// Behaviour switches for bots. + /// + private HashSet m_behaviourSwitches = new HashSet(); + + /// /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data /// public BotManager() @@ -163,20 +203,26 @@ namespace pCampBot /// The configuration for the bots to use public void dobotStartup(int botcount, IConfig startupConfig) { - string firstName = startupConfig.GetString("firstname"); - string lastNameStem = startupConfig.GetString("lastname"); - string password = startupConfig.GetString("password"); - string loginUri = startupConfig.GetString("loginuri"); - string startLocation = startupConfig.GetString("start", "last"); - int fromBotNumber = startupConfig.GetInt("from", 0); - string wearSetting = startupConfig.GetString("wear", "no"); + m_firstName = startupConfig.GetString("firstname"); + m_lastNameStem = startupConfig.GetString("lastname"); + m_password = startupConfig.GetString("password"); + m_loginUri = startupConfig.GetString("loginuri"); + m_fromBotNumber = startupConfig.GetInt("from", 0); + m_wearSetting = startupConfig.GetString("wear", "no"); - string startUri = ParseInputStartLocationToUri(startLocation); + m_startUri = ParseInputStartLocationToUri(startupConfig.GetString("start", "last")); - HashSet behaviourSwitches = new HashSet(); Array.ForEach( - startupConfig.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b)); + startupConfig.GetString("behaviours", "p").Split(new char[] { ',' }), b => m_behaviourSwitches.Add(b)); + + ConnectBots( + botcount, m_firstName, m_lastNameStem, m_password, m_loginUri, m_startUri, m_fromBotNumber, m_wearSetting, m_behaviourSwitches); + } + private void ConnectBots( + int botcount, string firstName, string lastNameStem, string password, string loginUri, string startUri, int fromBotNumber, string wearSetting, + HashSet behaviourSwitches) + { MainConsole.Instance.OutputFormat( "[BOT MANAGER]: Starting {0} bots connecting to {1}, location {2}, named {3} {4}_", botcount, @@ -194,7 +240,11 @@ namespace pCampBot lock (m_bots) { if (DisconnectingBots) + { + MainConsole.Instance.Output( + "[BOT MANAGER]: Aborting bot connection due to user-initiated disconnection"); break; + } string lastName = string.Format("{0}_{1}", lastNameStem, i + fromBotNumber); -- cgit v1.1 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 ++++++++++++++++++++++++++- OpenSim/Tools/pCampBot/pCampBot.cs | 5 +---- 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'OpenSim/Tools') 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; } /// diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index b02f917..e58b130 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -95,10 +95,7 @@ namespace pCampBot int botcount = commandLineConfig.GetInt("botcount", 1); - //startup specified number of bots. 1 is the default - Thread startBotThread = new Thread(o => bm.dobotStartup(botcount, commandLineConfig)); - startBotThread.Name = "Initial start bots thread"; - startBotThread.Start(); + bm.dobotStartup(botcount, commandLineConfig); while (true) { -- cgit v1.1 From 589b1a2eaf9058c3577b17ae76580a79ba855978 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Aug 2013 23:50:18 +0100 Subject: Make it possible to reconnect pCampbots with the console command "connect []". If no n is given then all available bots are connected --- OpenSim/Tools/pCampBot/Bot.cs | 96 ++++++++++++++++++------- OpenSim/Tools/pCampBot/BotManager.cs | 136 +++++++++++++++++++++-------------- OpenSim/Tools/pCampBot/pCampBot.cs | 3 +- 3 files changed, 155 insertions(+), 80 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index be7a5a1..f7af26e 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -158,8 +158,6 @@ namespace pCampBot behaviours.ForEach(b => b.Initialize(this)); - Client = new GridClient(); - Random = new Random(Environment.TickCount);// We do stuff randomly here FirstName = firstName; LastName = lastName; @@ -170,6 +168,59 @@ namespace pCampBot Manager = bm; Behaviours = behaviours; + + // Only calling for use as a template. + CreateLibOmvClient(); + } + + private void CreateLibOmvClient() + { + GridClient newClient = new GridClient(); + + if (Client != null) + { + newClient.Settings.LOGIN_SERVER = Client.Settings.LOGIN_SERVER; + newClient.Settings.ALWAYS_DECODE_OBJECTS = Client.Settings.ALWAYS_DECODE_OBJECTS; + newClient.Settings.AVATAR_TRACKING = Client.Settings.AVATAR_TRACKING; + newClient.Settings.OBJECT_TRACKING = Client.Settings.OBJECT_TRACKING; + newClient.Settings.SEND_AGENT_THROTTLE = Client.Settings.SEND_AGENT_THROTTLE; + newClient.Settings.SEND_AGENT_UPDATES = Client.Settings.SEND_AGENT_UPDATES; + newClient.Settings.SEND_PINGS = Client.Settings.SEND_PINGS; + newClient.Settings.STORE_LAND_PATCHES = Client.Settings.STORE_LAND_PATCHES; + newClient.Settings.USE_ASSET_CACHE = Client.Settings.USE_ASSET_CACHE; + newClient.Settings.MULTIPLE_SIMS = Client.Settings.MULTIPLE_SIMS; + newClient.Throttle.Asset = Client.Throttle.Asset; + newClient.Throttle.Land = Client.Throttle.Land; + newClient.Throttle.Task = Client.Throttle.Task; + newClient.Throttle.Texture = Client.Throttle.Texture; + newClient.Throttle.Wind = Client.Throttle.Wind; + newClient.Throttle.Total = Client.Throttle.Total; + } + else + { + newClient.Settings.LOGIN_SERVER = LoginUri; + newClient.Settings.ALWAYS_DECODE_OBJECTS = false; + newClient.Settings.AVATAR_TRACKING = false; + newClient.Settings.OBJECT_TRACKING = false; + newClient.Settings.SEND_AGENT_THROTTLE = true; + newClient.Settings.SEND_PINGS = true; + newClient.Settings.STORE_LAND_PATCHES = false; + newClient.Settings.USE_ASSET_CACHE = false; + newClient.Settings.MULTIPLE_SIMS = true; + newClient.Throttle.Asset = 100000; + newClient.Throttle.Land = 100000; + newClient.Throttle.Task = 100000; + newClient.Throttle.Texture = 100000; + newClient.Throttle.Wind = 100000; + newClient.Throttle.Total = 400000; + } + + newClient.Network.LoginProgress += this.Network_LoginProgress; + newClient.Network.SimConnected += this.Network_SimConnected; + newClient.Network.Disconnected += this.Network_OnDisconnected; + newClient.Objects.ObjectUpdate += Objects_NewPrim; + + Client = newClient; } //We do our actions here. This is where one would @@ -192,7 +243,7 @@ namespace pCampBot /// /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes. /// - public void shutdown() + public void Disconnect() { ConnectionState = ConnectionState.Disconnecting; @@ -202,34 +253,27 @@ namespace pCampBot Client.Network.Logout(); } + public void Connect() + { + Thread connectThread = new Thread(ConnectInternal); + connectThread.Name = Name; + connectThread.IsBackground = true; + + connectThread.Start(); + } + /// /// This is the bot startup loop. /// - public void startup() + private void ConnectInternal() { - Client.Settings.LOGIN_SERVER = LoginUri; - Client.Settings.ALWAYS_DECODE_OBJECTS = false; - Client.Settings.AVATAR_TRACKING = false; - Client.Settings.OBJECT_TRACKING = false; - Client.Settings.SEND_AGENT_THROTTLE = true; - Client.Settings.SEND_AGENT_UPDATES = false; - Client.Settings.SEND_PINGS = true; - Client.Settings.STORE_LAND_PATCHES = false; - Client.Settings.USE_ASSET_CACHE = false; - Client.Settings.MULTIPLE_SIMS = true; - Client.Throttle.Asset = 100000; - Client.Throttle.Land = 100000; - Client.Throttle.Task = 100000; - Client.Throttle.Texture = 100000; - Client.Throttle.Wind = 100000; - Client.Throttle.Total = 400000; - Client.Network.LoginProgress += this.Network_LoginProgress; - Client.Network.SimConnected += this.Network_SimConnected; - Client.Network.Disconnected += this.Network_OnDisconnected; - Client.Objects.ObjectUpdate += Objects_NewPrim; - ConnectionState = ConnectionState.Connecting; + // Current create a new client on each connect. libomv doesn't seem to process new sim + // information (e.g. EstablishAgentCommunication events) if connecting after a disceonnect with the same + // client + CreateLibOmvClient(); + if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", StartLocation, "Your name")) { ConnectionState = ConnectionState.Connected; @@ -474,6 +518,8 @@ namespace pCampBot // || args.Reason == NetworkManager.DisconnectType.NetworkTimeout) // && OnDisconnected != null) + + if ( (args.Reason == NetworkManager.DisconnectType.ClientInitiated || args.Reason == NetworkManager.DisconnectType.ServerInitiated diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index fe6048a..f40a84d 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -182,6 +182,12 @@ namespace pCampBot "bot", false, "quit", "quit", "Shutdown bots and exit", HandleShutdown); m_console.Commands.AddCommand( + "bot", false, "connect", "connect []", "Connect bots", + "If an is given, then the first disconnected bots by postfix number are connected.\n" + + "If no is given, then all currently disconnected bots are connected.", + HandleConnect); + + m_console.Commands.AddCommand( "bot", false, "disconnect", "disconnect []", "Disconnect bots", "Disconnecting bots will interupt any bot connection process, including connection on startup.\n" + "If an is given, then the last connected bots by postfix number are disconnected.\n" @@ -206,7 +212,7 @@ namespace pCampBot /// /// How many bots to start up /// The configuration for the bots to use - public void dobotStartup(int botcount, IConfig startupConfig) + public void CreateBots(int botcount, IConfig startupConfig) { m_firstName = startupConfig.GetString("firstname"); m_lastNameStem = startupConfig.GetString("lastname"); @@ -220,39 +226,55 @@ namespace pCampBot Array.ForEach( startupConfig.GetString("behaviours", "p").Split(new char[] { ',' }), b => m_behaviourSwitches.Add(b)); - ConnectBots( - botcount, m_firstName, m_lastNameStem, m_password, m_loginUri, m_startUri, m_fromBotNumber, m_wearSetting, m_behaviourSwitches); + for (int i = 0; i < botcount; i++) + { + lock (m_bots) + { + string lastName = string.Format("{0}_{1}", m_lastNameStem, i + m_fromBotNumber); + + // We must give each bot its own list of instantiated behaviours since they store state. + List behaviours = new List(); + + // Hard-coded for now + if (m_behaviourSwitches.Contains("c")) + behaviours.Add(new CrossBehaviour()); + + if (m_behaviourSwitches.Contains("g")) + behaviours.Add(new GrabbingBehaviour()); + + if (m_behaviourSwitches.Contains("n")) + behaviours.Add(new NoneBehaviour()); + + if (m_behaviourSwitches.Contains("p")) + behaviours.Add(new PhysicsBehaviour()); + + if (m_behaviourSwitches.Contains("t")) + behaviours.Add(new TeleportBehaviour()); + + CreateBot(this, behaviours, m_firstName, lastName, m_password, m_loginUri, m_startUri, m_wearSetting); + } + } } - private bool ConnectBots( - int botcount, string firstName, string lastNameStem, string password, string loginUri, string startUri, int fromBotNumber, string wearSetting, - HashSet behaviourSwitches) + public void ConnectBots(int botcount) { ConnectingBots = true; - Thread startBotThread - = new Thread( - o => ConnectBotsInternal( - botcount, firstName, lastNameStem, password, loginUri, startUri, fromBotNumber, wearSetting, - behaviourSwitches)); - - startBotThread.Name = "Bots connection thread"; - startBotThread.Start(); + Thread connectBotThread = new Thread(o => ConnectBotsInternal(botcount)); - return true; + connectBotThread.Name = "Bots connection thread"; + connectBotThread.Start(); } - private void ConnectBotsInternal( - int botcount, string firstName, string lastNameStem, string password, string loginUri, string startUri, int fromBotNumber, string wearSetting, - HashSet behaviourSwitches) + private void ConnectBotsInternal(int botcount) { MainConsole.Instance.OutputFormat( "[BOT MANAGER]: Starting {0} bots connecting to {1}, location {2}, named {3} {4}_", botcount, - loginUri, - startUri, - firstName, - lastNameStem); + m_loginUri, + m_startUri, + m_firstName, + m_lastNameStem); MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay); MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", InitBotSendAgentUpdates); @@ -269,28 +291,7 @@ namespace pCampBot break; } - string lastName = string.Format("{0}_{1}", lastNameStem, i + fromBotNumber); - - // We must give each bot its own list of instantiated behaviours since they store state. - List behaviours = new List(); - - // Hard-coded for now - if (behaviourSwitches.Contains("c")) - behaviours.Add(new CrossBehaviour()); - - if (behaviourSwitches.Contains("g")) - behaviours.Add(new GrabbingBehaviour()); - - if (behaviourSwitches.Contains("n")) - behaviours.Add(new NoneBehaviour()); - - if (behaviourSwitches.Contains("p")) - behaviours.Add(new PhysicsBehaviour()); - - if (behaviourSwitches.Contains("t")) - behaviours.Add(new TeleportBehaviour()); - - StartBot(this, behaviours, firstName, lastName, password, loginUri, startUri, wearSetting); + m_bots[i].Connect(); } // Stagger logins @@ -360,7 +361,7 @@ namespace pCampBot // } /// - /// This starts up the bot and stores the thread for the bot in the thread array + /// This creates a bot but does not start it. /// /// /// Behaviours for this bot to perform. @@ -370,12 +371,12 @@ namespace pCampBot /// Login URI /// Location to start the bot. Can be "last", "home" or a specific sim name. /// - public void StartBot( + public void CreateBot( BotManager bm, List behaviours, string firstName, string lastName, string password, string loginUri, string startLocation, string wearSetting) { MainConsole.Instance.OutputFormat( - "[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}", + "[BOT MANAGER]: Creating bot {0} {1}, behaviours are {2}", firstName, lastName, string.Join(",", behaviours.ConvertAll(b => b.Name).ToArray())); Bot pb = new Bot(bm, behaviours, firstName, lastName, password, startLocation, loginUri); @@ -387,12 +388,6 @@ namespace pCampBot pb.OnDisconnected += handlebotEvent; m_bots.Add(pb); - - Thread pbThread = new Thread(pb.startup); - pbThread.Name = pb.Name; - pbThread.IsBackground = true; - - pbThread.Start(); } /// @@ -427,6 +422,37 @@ namespace pCampBot return new LocalConsole("pCampbot"); } + private void HandleConnect(string module, string[] cmd) + { + if (ConnectingBots) + { + MainConsole.Instance.Output("Still connecting bots. Please wait for previous process to complete."); + return; + } + + lock (m_bots) + { + int botsToConnect; + int disconnectedBots = m_bots.Count(b => b.ConnectionState == ConnectionState.Disconnected); + + if (cmd.Length == 1) + { + botsToConnect = disconnectedBots; + } + else + { + if (!ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, cmd[1], out botsToConnect)) + return; + + botsToConnect = Math.Min(botsToConnect, disconnectedBots); + } + + MainConsole.Instance.OutputFormat("Connecting {0} bots", botsToConnect); + + ConnectBots(botsToConnect); + } + } + private void HandleDisconnect(string module, string[] cmd) { lock (m_bots) @@ -461,10 +487,12 @@ namespace pCampBot if (thisBot.ConnectionState == ConnectionState.Connected) { - Util.FireAndForget(o => thisBot.shutdown()); + Util.FireAndForget(o => thisBot.Disconnect()); disconnectedBots++; } } + + DisconnectingBots = false; } } diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index e58b130..ada39ee 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -95,7 +95,8 @@ namespace pCampBot int botcount = commandLineConfig.GetInt("botcount", 1); - bm.dobotStartup(botcount, commandLineConfig); + bm.CreateBots(botcount, commandLineConfig); + bm.ConnectBots(botcount); while (true) { -- cgit v1.1 From a3dd7db4a341f34e0df5b7fa4bddda4049e50acd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Aug 2013 00:08:47 +0100 Subject: Add -connect (-c) switch to pCampbot command line options. Now, bots will only connect at startup if this switch is specified. If it is not specified, then a separate "connect" command is required on the pCampbot command line --- OpenSim/Tools/pCampBot/pCampBot.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index ada39ee..fc67398 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -94,9 +94,12 @@ namespace pCampBot } int botcount = commandLineConfig.GetInt("botcount", 1); + bool startConnected = commandLineConfig.Get("connect") != null; bm.CreateBots(botcount, commandLineConfig); - bm.ConnectBots(botcount); + + if (startConnected) + bm.ConnectBots(botcount); while (true) { @@ -117,6 +120,7 @@ namespace pCampBot //Set up our nifty config.. thanks to nini ArgvConfigSource cs = new ArgvConfigSource(args); + cs.AddSwitch("Startup", "connect", "c"); cs.AddSwitch("Startup", "botcount", "n"); cs.AddSwitch("Startup", "from", "f"); cs.AddSwitch("Startup", "loginuri", "l"); @@ -143,20 +147,21 @@ namespace pCampBot "usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" + "Spawns a set of bots to test an OpenSim region\n\n" + " -l, -loginuri loginuri for grid/standalone (required)\n" - + " -s, -start optional start location for bots. Can be \"last\", \"home\" or a specific location with or without co-ords (e.g. \"region1\" or \"region2/50/30/90\"\n" - + " -firstname first name for the bots\n" - + " -lastname lastname for the bots. Each lastname will have _ appended, e.g. Ima Bot_0\n" - + " -password password for the bots\n" - + " -n, -botcount optional number of bots to start (default: 1)\n" - + " -f, -from optional starting number for login bot names, e.g. 25 will login Ima Bot_25, Ima Bot_26, etc. (default: 0)" - + " -b, behaviours behaviours for bots. Comma separated, e.g. p,g. Default is p\n" + + " -s, -start start location for bots (optional). Can be \"last\", \"home\" or a specific location with or without co-ords (e.g. \"region1\" or \"region2/50/30/90\"\n" + + " -firstname first name for the bots (required)\n" + + " -lastname lastname for the bots (required). Each lastname will have _ appended, e.g. Ima Bot_0\n" + + " -password password for the bots (required)\n" + + " -n, -botcount number of bots to start (default: 1) (optional)\n" + + " -f, -from starting number for login bot names, e.g. 25 will login Ima Bot_25, Ima Bot_26, etc. (default: 0) (optional)\n" + + " -c, -connect connect all bots at startup (optional)\n" + + " -b, behaviours behaviours for bots. Comma separated, e.g. p,g. Default is p (required)\n" + " current options are:\n" + " p (physics - bots constantly move and jump around)\n" + " g (grab - bots randomly click prims whether set clickable or not)\n" + " n (none - bots do nothing)\n" + " t (teleport - bots regularly teleport between regions on the grid)\n" -// " c (cross)" + - + " -wear optional folder from which to load appearance data, \"no\" if there is no such folder (default: no)\n" +// " c (cross)\n" + + + " -wear folder from which to load appearance data, \"no\" if there is no such folder (default: no) (optional)\n" + " -h, -help show this message.\n"); } } -- cgit v1.1 From 56d1d67a34bbd3e597168ab9bfa43be6a34e580a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Aug 2013 17:01:12 +0100 Subject: Add pCampbot console commands to sit all bots on ground and stand all bots --- OpenSim/Tools/pCampBot/Bot.cs | 24 ++++++++++++ OpenSim/Tools/pCampBot/BotManager.cs | 74 +++++++++++++----------------------- 2 files changed, 51 insertions(+), 47 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index f7af26e..27c086e 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -318,6 +318,30 @@ namespace pCampBot } } + /// + /// Sit this bot on the ground. + /// + public void SitOnGround() + { + if (ConnectionState == ConnectionState.Connected) + Client.Self.SitOnGround(); + } + + /// + /// Stand this bot + /// + public void Stand() + { + if (ConnectionState == ConnectionState.Connected) + { + // Unlike sit on ground, here libomv checks whether we have SEND_AGENT_UPDATES enabled. + bool prevUpdatesSetting = Client.Settings.SEND_AGENT_UPDATES; + Client.Settings.SEND_AGENT_UPDATES = true; + Client.Self.Stand(); + Client.Settings.SEND_AGENT_UPDATES = prevUpdatesSetting; + } + } + public void SaveDefaultAppearance() { saveDir = "MyAppearance/" + FirstName + "_" + LastName; diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index f40a84d..f5b5256 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -195,14 +195,18 @@ namespace pCampBot HandleDisconnect); m_console.Commands.AddCommand( - "bot", false, "show regions", "show regions", "Show regions known to bots", HandleShowRegions); + "bot", false, "sit", "sit", "Sit all bots on the ground.", + HandleSit); + + m_console.Commands.AddCommand( + "bot", false, "stand", "stand", "Stand all bots.", + HandleStand); m_console.Commands.AddCommand( - "bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowStatus); + "bot", false, "show regions", "show regions", "Show regions known to bots", HandleShowRegions); -// m_console.Commands.AddCommand("bot", false, "add bots", -// "add bots ", -// "Add more bots", HandleAddBots); + m_console.Commands.AddCommand( + "bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowBotsStatus); m_bots = new List(); } @@ -340,26 +344,6 @@ namespace pCampBot return string.Format("uri:{0}&{1}&{2}&{3}", regionName, startPos.X, startPos.Y, startPos.Z); } -// /// -// /// Add additional bots (and threads) to our bot pool -// /// -// /// How Many of them to add -// public void addbots(int botcount) -// { -// int len = m_td.Length; -// Thread[] m_td2 = new Thread[len + botcount]; -// for (int i = 0; i < len; i++) -// { -// m_td2[i] = m_td[i]; -// } -// m_td = m_td2; -// int newlen = len + botcount; -// for (int i = len; i < newlen; i++) -// { -// startupBot(Config); -// } -// } - /// /// This creates a bot but does not start it. /// @@ -496,6 +480,22 @@ namespace pCampBot } } + private void HandleSit(string module, string[] cmd) + { + lock (m_bots) + { + m_bots.ForEach(b => b.SitOnGround()); + } + } + + private void HandleStand(string module, string[] cmd) + { + lock (m_bots) + { + m_bots.ForEach(b => b.Stand()); + } + } + private void HandleShutdown(string module, string[] cmd) { lock (m_bots) @@ -529,7 +529,7 @@ namespace pCampBot } } - private void HandleShowStatus(string module, string[] cmd) + private void HandleShowBotsStatus(string module, string[] cmd) { ConsoleDisplayTable cdt = new ConsoleDisplayTable(); cdt.AddColumn("Name", 30); @@ -563,26 +563,6 @@ namespace pCampBot MainConsole.Instance.Output(cdl.ToString()); } - /* - private void HandleQuit(string module, string[] cmd) - { - m_console.Warn("DANGER", "This should only be used to quit the program if you've already used the shutdown command and the program hasn't quit"); - Environment.Exit(0); - } - */ -// -// private void HandleAddBots(string module, string[] cmd) -// { -// int newbots = 0; -// -// if (cmd.Length > 2) -// { -// Int32.TryParse(cmd[2], out newbots); -// } -// if (newbots > 0) -// addbots(newbots); -// } - internal void Grid_GridRegion(object o, GridRegionEventArgs args) { lock (RegionsKnown) @@ -602,4 +582,4 @@ namespace pCampBot } } } -} +} \ No newline at end of file -- cgit v1.1 From a3e1b278a1d82e231f85bf0bf181ed79bbdaa7f2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Aug 2013 18:41:09 +0100 Subject: Add pCampbot "show bot" console command to show more detailed information on a particular bot (e.g. what sims they are connected to) --- OpenSim/Tools/pCampBot/Bot.cs | 11 +++++++- OpenSim/Tools/pCampBot/BotManager.cs | 49 +++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index 27c086e..d418288 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -97,11 +97,20 @@ namespace pCampBot /// public ConnectionState ConnectionState { get; private set; } + public List Simulators + { + get + { + lock (Client.Network.Simulators) + return new List(Client.Network.Simulators); + } + } + /// /// The number of connections that this bot has to different simulators. /// /// Includes both root and child connections. - public int ConnectionsCount + public int SimulatorsCount { get { diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index f5b5256..303c8dd 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -208,6 +208,10 @@ namespace pCampBot m_console.Commands.AddCommand( "bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowBotsStatus); + m_console.Commands.AddCommand( + "bot", false, "show bot", "show bot ", + "Shows the detailed status and settings of a particular bot.", HandleShowBotStatus); + m_bots = new List(); } @@ -549,7 +553,7 @@ namespace pCampBot totals[pb.ConnectionState]++; cdt.AddRow( - pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState, pb.ConnectionsCount); + pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState, pb.SimulatorsCount); } } @@ -563,6 +567,49 @@ namespace pCampBot MainConsole.Instance.Output(cdl.ToString()); } + private void HandleShowBotStatus(string module, string[] cmd) + { + if (cmd.Length != 4) + { + MainConsole.Instance.Output("Usage: show bot "); + return; + } + + string name = string.Format("{0} {1}", cmd[2], cmd[3]); + + Bot bot; + + lock (m_bots) + bot = m_bots.Find(b => b.Name == name); + + if (bot == null) + { + MainConsole.Instance.Output("No bot found with name {0}", name); + return; + } + + ConsoleDisplayList cdl = new ConsoleDisplayList(); + cdl.AddRow("Name", bot.Name); + cdl.AddRow("Status", bot.ConnectionState); + + Simulator currentSim = bot.Client.Network.CurrentSim; + cdl.AddRow("Region", currentSim != null ? currentSim.Name : "(none)"); + + List connectedSimulators = bot.Simulators; + List simulatorNames = connectedSimulators.ConvertAll(cs => cs.Name); + cdl.AddRow("Connections", string.Join(", ", simulatorNames)); + + MainConsole.Instance.Output(cdl.ToString()); + + MainConsole.Instance.Output("Settings"); + + ConsoleDisplayList statusCdl = new ConsoleDisplayList(); + GridClient botClient = bot.Client; + statusCdl.AddRow("SEND_AGENT_UPDATES", botClient.Settings.SEND_AGENT_UPDATES); + + MainConsole.Instance.Output(statusCdl.ToString()); + } + internal void Grid_GridRegion(object o, GridRegionEventArgs args) { lock (RegionsKnown) -- cgit v1.1 From 4a81465b91b6506200157f8679ae9192cd43b45f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Aug 2013 18:47:52 +0100 Subject: Fix build break from last commit a3e1b27 on mono 2.4.3 Looks like this level of mono doesn't have a string.Join() which will take a list rather than an array (or some implicit conversion isn't happening) --- OpenSim/Tools/pCampBot/BotManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 303c8dd..13912ae 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -597,7 +597,7 @@ namespace pCampBot List connectedSimulators = bot.Simulators; List simulatorNames = connectedSimulators.ConvertAll(cs => cs.Name); - cdl.AddRow("Connections", string.Join(", ", simulatorNames)); + cdl.AddRow("Connections", string.Join(", ", simulatorNames.ToArray())); MainConsole.Instance.Output(cdl.ToString()); -- cgit v1.1 From 66a7dc3a0de599068ea257cc2cefbbe4b95599c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Aug 2013 20:12:14 +0100 Subject: In pCampbot, don't try and reconnect bots that are already connected on console "connect" command --- OpenSim/Tools/pCampBot/BotManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 13912ae..245c460 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -299,7 +299,8 @@ namespace pCampBot break; } - m_bots[i].Connect(); + if (m_bots[i].ConnectionState == ConnectionState.Disconnected) + m_bots[i].Connect(); } // Stagger logins -- cgit v1.1 From 51c7fb1969f4850750de4b37827e5e2e9d85f3e0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Aug 2013 23:11:05 +0100 Subject: Add "set bots" command to make it possible to set SEND_AGENT_UPDATES on all bots whilst pCampbot is running --- OpenSim/Tools/pCampBot/BotManager.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 245c460..c335a6e 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -203,6 +203,9 @@ namespace pCampBot HandleStand); m_console.Commands.AddCommand( + "bot", false, "set bots", "set bots ", "Set a setting for all bots.", HandleSetBots); + + m_console.Commands.AddCommand( "bot", false, "show regions", "show regions", "Show regions known to bots", HandleShowRegions); m_console.Commands.AddCommand( @@ -519,6 +522,30 @@ namespace pCampBot Environment.Exit(0); } + private void HandleSetBots(string module, string[] cmd) + { + string key = cmd[2]; + string rawValue = cmd[3]; + + if (key == "SEND_AGENT_UPDATES") + { + bool newSendAgentUpdatesSetting; + + if (!ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, rawValue, out newSendAgentUpdatesSetting)) + return; + + MainConsole.Instance.OutputFormat( + "Setting SEND_AGENT_UPDATES to {0} for all bots", newSendAgentUpdatesSetting); + + lock (m_bots) + m_bots.ForEach(b => b.Client.Settings.SEND_AGENT_UPDATES = newSendAgentUpdatesSetting); + } + else + { + MainConsole.Instance.Output("Error: Only setting currently available is SEND_AGENT_UPDATES"); + } + } + private void HandleShowRegions(string module, string[] cmd) { string outputFormat = "{0,-30} {1, -20} {2, -5} {3, -5}"; -- cgit v1.1 From 70f89ae65b09e9c2f0dc63cb416fea4cceb7dd13 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Aug 2013 23:43:33 +0100 Subject: Make it possible to adjust the pCampbot login delay via the [BotManager] LoginDelay parameter of pCampbot.ini --- OpenSim/Tools/pCampBot/pCampBot.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index fc67398..aee5864 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -82,6 +82,13 @@ namespace pCampBot IConfigSource configSource = new IniConfigSource(iniFilePath); + IConfig botManagerConfig = configSource.Configs["BotManager"]; + + if (botManagerConfig != null) + { + bm.LoginDelay = botManagerConfig.GetInt("LoginDelay", bm.LoginDelay); + } + IConfig botConfig = configSource.Configs["Bot"]; if (botConfig != null) -- cgit v1.1 From 13556cf1296d3c928d6eb286a6a1c9058c9ab5e7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Aug 2013 23:49:19 +0100 Subject: Fix a further bug in pCampbot connect where ignoring already connected bots was wrongly counted as a connect Also, only sleep when we actually perform a connection --- OpenSim/Tools/pCampBot/BotManager.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index c335a6e..50a77ed 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -277,11 +277,11 @@ namespace pCampBot connectBotThread.Start(); } - private void ConnectBotsInternal(int botcount) + private void ConnectBotsInternal(int botCount) { MainConsole.Instance.OutputFormat( "[BOT MANAGER]: Starting {0} bots connecting to {1}, location {2}, named {3} {4}_", - botcount, + botCount, m_loginUri, m_startUri, m_firstName, @@ -291,7 +291,9 @@ namespace pCampBot MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", InitBotSendAgentUpdates); MainConsole.Instance.OutputFormat("[BOT MANAGER]: InitBotRequestObjectTextures is {0}", InitBotRequestObjectTextures); - for (int i = 0; i < botcount; i++) + int connectedBots = 0; + + for (int i = 0; i < m_bots.Count; i++) { lock (m_bots) { @@ -303,11 +305,17 @@ namespace pCampBot } if (m_bots[i].ConnectionState == ConnectionState.Disconnected) + { m_bots[i].Connect(); - } + connectedBots++; - // Stagger logins - Thread.Sleep(LoginDelay); + if (connectedBots >= botCount) + break; + + // Stagger logins + Thread.Sleep(LoginDelay); + } + } } ConnectingBots = false; -- cgit v1.1 From 050617ae0ec13075db36449e8e5a4616c8bcd96e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 Aug 2013 01:13:19 +0100 Subject: Make pCampbot "show bot" command take the bot number instead of the full bot name Shorter and can do this because bot names are uniform --- OpenSim/Tools/pCampBot/BotManager.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 50a77ed..5c3835b 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -212,7 +212,7 @@ namespace pCampBot "bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowBotsStatus); m_console.Commands.AddCommand( - "bot", false, "show bot", "show bot ", + "bot", false, "show bot", "show bot ", "Shows the detailed status and settings of a particular bot.", HandleShowBotStatus); m_bots = new List(); @@ -605,13 +605,18 @@ namespace pCampBot private void HandleShowBotStatus(string module, string[] cmd) { - if (cmd.Length != 4) + if (cmd.Length != 3) { - MainConsole.Instance.Output("Usage: show bot "); + MainConsole.Instance.Output("Usage: show bot "); return; } - string name = string.Format("{0} {1}", cmd[2], cmd[3]); + int botNumber; + + if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, cmd[2], out botNumber)) + return; + + string name = string.Format("{0} {1}_{2}", m_firstName, m_lastNameStem, botNumber); Bot bot; -- cgit v1.1 From 1a623bb266e78c9dc2648038de7b67d81b5a417e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 Aug 2013 20:58:22 +0100 Subject: Rename pCampbot.ini -> pCampBot.ini (and example file) to be consistent with other capitalizations of pCampBot --- OpenSim/Tools/pCampBot/pCampBot.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Tools') diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index aee5864..781bb00 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -51,7 +51,7 @@ namespace pCampBot { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public const string ConfigFileName = "pCampbot.ini"; + public const string ConfigFileName = "pCampBot.ini"; [STAThread] public static void Main(string[] args) -- cgit v1.1