Esempio n. 1
0
        /// <summary>
        /// When connection has been lost
        /// </summary>
        public void OnConnectionLost(ChatBot.DisconnectReason reason, string message)
        {
            world.Clear();

            bool will_restart = false;

            switch (reason)
            {
            case ChatBot.DisconnectReason.ConnectionLost:
                message = "Connection has been lost.";
                ConsoleIO.WriteLine(message);
                break;

            case ChatBot.DisconnectReason.InGameKick:
                ConsoleIO.WriteLine("Disconnected by Server :");
                ConsoleIO.WriteLineFormatted(message);
                break;

            case ChatBot.DisconnectReason.LoginRejected:
                ConsoleIO.WriteLine("Login failed :");
                ConsoleIO.WriteLineFormatted(message);
                break;
            }

            foreach (ChatBot bot in bots)
            {
                will_restart |= bot.OnDisconnect(reason, message);
            }

            if (!will_restart)
            {
                Program.HandleFailure();
            }
        }
        /// <summary>
        /// When connection has been lost, login was denied or played was kicked from the server
        /// </summary>
        public void OnConnectionLost(ChatBot.DisconnectReason reason, string message)
        {
            world.Clear();

            if (timeoutdetector != null)
            {
                timeoutdetector.Abort();
                timeoutdetector = null;
            }

            bool will_restart = false;

            switch (reason)
            {
            case ChatBot.DisconnectReason.ConnectionLost:
                message = "Connection has been lost.";
                ConsoleIO.WriteLine(message);
                break;

            case ChatBot.DisconnectReason.InGameKick:
                ConsoleIO.WriteLine("Disconnected by Server :");
                ConsoleIO.WriteLineFormatted(message);
                break;

            case ChatBot.DisconnectReason.LoginRejected:
                ConsoleIO.WriteLine("Login failed :");
                ConsoleIO.WriteLineFormatted(message);
                break;

            case ChatBot.DisconnectReason.UserLogout:
                throw new InvalidOperationException("User-initiated logout should be done by calling Disconnect()");
            }

            foreach (ChatBot bot in bots.ToArray())
            {
                will_restart |= bot.OnDisconnect(reason, message);
            }

            if (!will_restart)
            {
                Program.HandleFailure();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// When connection has been lost
        /// </summary>
        public void OnConnectionLost(ChatBot.DisconnectReason reason, string message)
        {
            bool will_restart = false;

            switch (reason)
            {
            case ChatBot.DisconnectReason.ConnectionLost:
                message = "§3[Conexão]§c Desconectado do servidor: Conexão perdida!";
                ConsoleIO.WriteLineFormatted(message);
                break;

            case ChatBot.DisconnectReason.InGameKick:
                ConsoleIO.WriteLineFormatted("§3[Conexão]§c Desconectado pelo servidor: " + message);
                break;

            case ChatBot.DisconnectReason.LoginRejected:
                ConsoleIO.WriteLineFormatted("§3[Conexão]§c Erro ao conectar: " + message);
                if (message.StartsWith("[Sistema Anti DC]"))
                {
                    Program.Restart(7);
                }
                break;
            }

            if (!message.StartsWith("[Sistema Anti DC]"))
            {
                foreach (ChatBot bot in bots)
                {
                    will_restart |= bot.OnDisconnect(reason, message);
                }

                if (!will_restart)
                {
                    Program.HandleFailure();
                }
            }
        }
Esempio n. 4
0
 public void OnConnectionLost(ChatBot.DisconnectReason reason, string message)
 {
 }