From dc39ec82fa8343657ad9b45a7d9cfeb27bf26e79 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 11 May 2012 00:53:21 +0100 Subject: Change bot.IsConnected to be ConnectionState with Disconnected, Connecting, Connnected and Disconnecting states --- OpenSim/Tools/pCampBot/Bot.cs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'OpenSim/Tools/pCampBot/Bot.cs') diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index da090dd..2b4a171 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -43,6 +43,14 @@ using Timer = System.Timers.Timer; namespace pCampBot { + public enum ConnectionState + { + Disconnected, + Connecting, + Connected, + Disconnecting + } + public class Bot { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -86,7 +94,7 @@ namespace pCampBot /// /// Is this bot connected to the grid? /// - public bool IsConnected { get; private set; } + public ConnectionState ConnectionState { get; private set; } public string FirstName { get; private set; } public string LastName { get; private set; } @@ -130,6 +138,8 @@ namespace pCampBot BotManager bm, List behaviours, string firstName, string lastName, string password, string loginUri) { + ConnectionState = ConnectionState.Disconnected; + behaviours.ForEach(b => b.Initialize(this)); Client = new GridClient(); @@ -178,6 +188,8 @@ namespace pCampBot /// public void shutdown() { + ConnectionState = ConnectionState.Disconnecting; + if (m_actionThread != null) m_actionThread.Abort(); @@ -209,9 +221,11 @@ namespace pCampBot Client.Network.Disconnected += this.Network_OnDisconnected; Client.Objects.ObjectUpdate += Objects_NewPrim; + ConnectionState = ConnectionState.Connecting; + if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) { - IsConnected = true; + ConnectionState = ConnectionState.Connected; Thread.Sleep(Random.Next(1000, 10000)); m_actionThread = new Thread(Action); @@ -241,6 +255,8 @@ namespace pCampBot } else { + ConnectionState = ConnectionState.Disconnected; + m_log.ErrorFormat( "{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage); @@ -439,6 +455,8 @@ namespace pCampBot public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) { + ConnectionState = ConnectionState.Disconnected; + m_log.DebugFormat( "[BOT]: Bot {0} disconnected reason {1}, message {2}", Name, args.Reason, args.Message); @@ -456,7 +474,6 @@ namespace pCampBot && OnDisconnected != null) // if (OnDisconnected != null) { - IsConnected = false; OnDisconnected(this, EventType.DISCONNECTED); } } -- cgit v1.1 From f231ac39de7348965b5c4c04d8b29a885501c90d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 11 May 2012 02:23:18 +0100 Subject: Increase minimum period between bot actions to 3 seconds, so that teleport doesn't fall under the minimum 2 second limits that clients take to process it --- OpenSim/Tools/pCampBot/Bot.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Tools/pCampBot/Bot.cs') diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index 2b4a171..95dba9f 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -167,10 +167,10 @@ namespace pCampBot Behaviours.ForEach( b => { + Thread.Sleep(Random.Next(3000, 10000)); + // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); b.Action(); - - Thread.Sleep(Random.Next(1000, 10000)); } ); } -- cgit v1.1 From 480216f50f40bdb9709f9c6eec189a2ca027f395 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 11 May 2012 02:38:29 +0100 Subject: Print out more information on connecting bots --- OpenSim/Tools/pCampBot/Bot.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Tools/pCampBot/Bot.cs') diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index 95dba9f..b6cd287 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -168,7 +168,7 @@ namespace pCampBot b => { Thread.Sleep(Random.Next(3000, 10000)); - + // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); b.Action(); } -- cgit v1.1 From c215b1ad169cb8c3add70622f610e980ee9cfa31 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 8 Jun 2012 03:53:03 +0100 Subject: If logging a client out due to ack timeout, do this asynchronously rather than synchronously on the outgoing packet loop. This is the same async behaviour as normal logouts. This is necessary because the event queue will sleep the thread for 5 seconds on an ack timeout logout as the client isn't around to pick up the final event queue messages. --- OpenSim/Tools/pCampBot/Bot.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Tools/pCampBot/Bot.cs') diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index b6cd287..daaa3c0 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -480,6 +480,9 @@ namespace pCampBot public void Objects_NewPrim(object sender, PrimEventArgs args) { +// if (Name.EndsWith("4")) +// throw new Exception("Aaargh"); + Primitive prim = args.Prim; if (prim != null) -- cgit v1.1