Esempio n. 1
0
 internal MinecraftBot(TcpClient tcp, string host, int port, int protocolver, ForgeInfo forge, tBotsTask_b s)
 {
     this.Tcp        = tcp;
     ProtocolVersion = protocolver;
     Host            = host;
     Port            = port;
     forgeInfo       = forge;
     bots            = s;
 }
Esempio n. 2
0
        public static void Init()
        {
            try
            {
                SetServerIP();
                Console.WriteLine("测试方案:");
                Console.WriteLine("1:(代理)Proxy-Bots 并发压测测试.");
                Console.WriteLine("2:(代理)Proxy-Bots 队列算法测试.(不支持Motd)");
                int           Method = int.Parse(Console.ReadLine());
                ArrayList     chat2  = new ArrayList();
                List <string> chat   = new List <string>();
                ServerInfo    info   = new ServerInfo(ServerIP, ServerPort);
                if (info.StartGetServerInfo())
                {
                    int protocol = info.ProtocolVersion;
                    PrintServerInfo(info, ref protocol);
                    Helper.WriteLogs(info.ServerIP, info.ServerPort, info.GameVersion, Setting.threads);
                    switch (Method)
                    {
                    case 1:
                        chat.AddRange(File.ReadAllText(Setting.chatlist, Encoding.UTF8).Split('\n'));
                        Bot.tBotsTask_a s_a;
                        if (Setting.protocol == 0)
                        {
                            s_a = new Bot.tBotsTask_a(info, Setting.name, Setting.threads, chat, protocol);
                        }
                        else
                        {
                            s_a = new Bot.tBotsTask_a(info, Setting.name, Setting.threads, chat, Setting.protocol);
                        }
                        s_a.newTask(Setting.cooldown);
                        break;

                    case 2:
                        chat.AddRange(File.ReadAllText(Setting.chatlist, Encoding.UTF8).Split('\n'));
                        Bot.tBotsTask_b s_b;
                        if (Setting.protocol == 0)
                        {
                            s_b = new Bot.tBotsTask_b(info, Setting.name, Setting.threads, chat2, protocol);
                        }
                        else
                        {
                            s_b = new Bot.tBotsTask_b(info, Setting.name, Setting.threads, chat2, Setting.protocol);
                        }
                        s_b.newTask(Setting.cooldown);
                        break;

                    default:
                        Console.WriteLine("未提供相应方案,请重新选择");
                        Init();
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("取服务器信息失败,请重试..");
                    Program.Exit();
                }
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }