Beispiel #1
0
        /// <summary>
        /// Delegate method called by the invocation buffer after a bot has crashed.
        /// This method attempts to reconnect the bot.
        /// </summary>
        /// <param name="botObj"></param>
        private void HandleCrash(object botObj)
        {
            VTankBot bot = (VTankBot)botObj;

            Print("Restarting bot {0}...", bot.TankName);

            AddBot(bot.GetType(), bot.AuthInfo.Username, bot.AuthInfo.Password);

            /*try
             * {
             *  AddBot(bot.GetType(), bot.AuthInfo.Username, bot.AuthInfo.Password);
             * }
             * catch (Exception e)
             * {
             *  string errorMessage = e.Message;
             *  Exception inner = e.InnerException;
             *  while (inner != null)
             *  {
             *      errorMessage = inner.Message;
             *      inner = inner.InnerException;
             *  }
             *
             *  // Re-connect attempt failed -- try again soon.
             *  Print("{0} can't reconnect (trying again soon): {1}",
             *      bot.AuthInfo.Username, errorMessage);
             *  Console.Error.WriteLine();
             *  Console.Error.WriteLine(e.ToString());
             *  Console.Error.WriteLine();
             *
             *  buffer.Enqueue(new Invocation.InvocationTarget(HandleCrash),
             *      botObj, WaitTimeReconnect * 2);
             * }*/
        }
Beispiel #2
0
        /// <summary>
        /// Move a bot from the reserved list to the online list.
        /// </summary>
        /// <param name="username"></param>
        public void MoveBotFromReserve(VTankBot bot)
        {
            try
            {
                AddBot(bot.GetType(), bot.AuthInfo.Username, bot.AuthInfo.Password);
                reservedList.Remove(bot);

                Print(String.Format("Bot {0} moved from reserve.", bot.AuthInfo.Username));
            }
            catch (Exception ex)
            {
                Print(ex.ToString());
            }

            if (OnBotChange != null)
            {
                OnBotChange(bot);
            }
        }