示例#1
1
        private static void Main(string[] args)
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
                Console.WriteLine("Press <Enter> to start emulation...");
                Console.ReadLine();

                int threads;
                int iothreads;
                ThreadPool.GetMinThreads(out threads, out iothreads);

                DedicatedThreadPool threadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(threads));

                ThreadPool.SetMinThreads(32000, 4000);
                ThreadPool.SetMaxThreads(32000, 4000);

                Emulator emulator = new Emulator {Running = true};
                Stopwatch watch = new Stopwatch();
                watch.Start();

                long start = DateTime.UtcNow.Ticks;

                //IPEndPoint endPoint = new IPEndPoint(Dns.GetHostEntry("yodamine.com").AddressList[0], 19132);
                IPEndPoint endPoint = new IPEndPoint(IPAddress.Loopback, 19132);

                for (int j = 0; j < NumberOfBots; j++)
                {
                    string playerName = $"TheGrey{j + 1:D3}";

                    ClientEmulator client = new ClientEmulator(threadPool, emulator, DurationOfConnection,
                        playerName, (int) (DateTime.UtcNow.Ticks - start), endPoint,
                        RanSleepMin, RanSleepMax, RequestChunkRadius);

                    new Thread(o => { client.EmulateClient(); }) {IsBackground = true}.Start();
                    //ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

                    Thread.Sleep(TimeBetweenSpawns);
                }

                Console.WriteLine("Press <enter> to stop all clients.");
                Console.ReadLine();
                emulator.Running = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }
示例#2
0
 public ClientEmulator(Emulator emulator, int timeToRun, string name, int clientId)
 {
     Emulator = emulator;
     TimeToRun = timeToRun;
     Name = name;
     ClientId = clientId;
 }
示例#3
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Clients sleeping...");
            Thread.Sleep(1000); // Let the server start first

            Console.ReadLine();

            var emulator = new Emulator();
            ThreadPool.SetMinThreads(1000, 1000);
            //ThreadPool.SetMaxThreads(2000, 2000);

            int[] counter = {0};
            Random random = new Random();
            for (int i = 0; i < 300; i++)
            {
                counter[0]++;
                string playerName = string.Format("Player {0}", (i + 1));
                //string playerName = "Player " + Guid.NewGuid();
                ThreadPool.QueueUserWorkItem(emulator.EmulateClient, playerName);
                Thread.Sleep(random.Next(150, 1100));
            }

            Console.WriteLine("Clients done. Press <enter> to exit.");

            Console.ReadLine();
            _running = false;
            Console.ReadLine();
        }
示例#4
0
		private static void Main(string[] args)
		{
			AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
			Console.WriteLine("Press <Enter> to start emulation...");
			Console.ReadLine();

			ThreadPool.SetMinThreads(1000, 1000);

			Emulator emulator = new Emulator {Running = true};
			Random random = new Random();

			//{
			//	Stopwatch watch = new Stopwatch();
			//	watch.Start();
			//	int i = 0;
			//	while (watch.ElapsedMilliseconds < 300*1000)
			//	{
			//		if (i > 0 && i%10 == 0) Thread.Sleep(10000);

			//		string playerName = string.Format("Player-{0}", (i + 1));
			//		//string playerName = "Player " + Guid.NewGuid();
			//		ClientEmulator client = new ClientEmulator(emulator, random.Next(60, 120)*1000, playerName, i)
			//		{
			//			Random = random
			//		};
			//		ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

			//		Thread.Sleep(500);

			//		i++;
			//	}
			//}

			{
				Stopwatch watch = new Stopwatch();
				watch.Start();
				for (int j = 0; j < 100; j++)
				{
					string playerName = string.Format("Player-{0}", (j + 1));
					ClientEmulator client = new ClientEmulator(emulator, 300*1000, playerName, j)
					{
						Random = random
					};
					ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

					Thread.Sleep(500);
				}
			}

			Thread.Sleep(300000);

			Console.WriteLine("Press <enter> to stop all clients.");

			Console.ReadLine();
			emulator.Running = false;

			Console.WriteLine("Emulation complete. Press <enter> to exit.");
			Console.ReadLine();
		}
示例#5
0
 public ClientEmulator(DedicatedThreadPool threadPool, Emulator emulator, TimeSpan timeToRun, string name, int clientId, IPEndPoint endPoint, int ranMin = 150, int ranMax = 450, int chunkRadius = 8)
 {
     _threadPool = threadPool;
     Emulator = emulator;
     TimeToRun = timeToRun;
     Name = name;
     ClientId = clientId;
     EndPoint = endPoint;
     RanMin = ranMin;
     RanMax = ranMax;
     ChunkRadius = chunkRadius;
 }
示例#6
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Press <Enter> to start emulation...");
            Console.ReadLine();

            ThreadPool.SetMinThreads(1000, 1000);

            Emulator emulator = new Emulator {Running = true};
            Random random = new Random();

            {
                Stopwatch watch = new Stopwatch();
                watch.Start();
                int i = 0;
                while (watch.ElapsedMilliseconds < 300*1000)
                {
                    if (i > 0 && i%10 == 0) Thread.Sleep(10000);

                    string playerName = string.Format("Player-{0}", (i + 1));
                    //string playerName = "Player " + Guid.NewGuid();
                    ClientEmulator client = new ClientEmulator(emulator, random.Next(60, 120)*1000, playerName, i)
                    {
                        Random = random
                    };
                    ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

                    Thread.Sleep(200);

                    i++;
                }
            }

            Console.WriteLine("Press <enter> to stop all clients.");

            Console.ReadLine();
            emulator.Running = false;

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }
示例#7
0
        private static void Main(string[] args)
        {
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.xml"));

            try
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
                Console.WriteLine("Press <Enter> to start emulation...");
                Console.ReadLine();

                //int threads;
                //int iothreads;

                //ThreadPool.GetMaxThreads(out threads, out iothreads);
                //ThreadPool.SetMaxThreads(threads, 4000);

                //ThreadPool.GetMinThreads(out threads, out iothreads);
                //ThreadPool.SetMinThreads(4000, 4000);

                //DedicatedThreadPool threadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount));
                DedicatedThreadPool threadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(4000));

                Emulator emulator = new Emulator {
                    Running = true
                };
                Stopwatch watch = new Stopwatch();
                watch.Start();

                long start = DateTime.UtcNow.Ticks;

                //IPEndPoint endPoint = new IPEndPoint(Dns.GetHostEntry("yodamine.com").AddressList[0], 19132);
                IPEndPoint endPoint = new IPEndPoint(IPAddress.Loopback, 19132);

                var sw = Stopwatch.StartNew();
                for (int j = 0; j < NumberOfBots; j++)
                {
                    string playerName = $"TheGrey{j + 1:D3}";

                    ClientEmulator client = new ClientEmulator(threadPool, emulator, DurationOfConnection,
                                                               playerName, (int)(DateTime.UtcNow.Ticks - start), endPoint,
                                                               RanSleepMin, RanSleepMax, RequestChunkRadius);

                    new Thread(o => { client.EmulateClient(); })
                    {
                        IsBackground = true
                    }.Start();

                    if (ConcurrentSpawn)
                    {
                        emulator.ConcurrentSpawnWaitHandle.Set();
                    }

                    emulator.ConcurrentSpawnWaitHandle.WaitOne();

                    long elapsed = sw.ElapsedMilliseconds;
                    if (elapsed < TimeBetweenSpawns)
                    {
                        Thread.Sleep((int)(TimeBetweenSpawns - elapsed));
                    }

                    sw.Restart();
                }

                Console.WriteLine("Press <enter> to stop all clients.");
                Console.ReadLine();
                emulator.Running = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }
示例#8
0
        private static void Main(string[] args)
        {
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "log4net.xml")));

            Console.ResetColor();
            Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(MiNetServer.MiNET);
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;

            try
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
                Console.WriteLine("Press <Enter> to start emulation...");
                Console.ReadLine();

                //int threads;
                //int iothreads;

                //ThreadPool.GetMaxThreads(out threads, out iothreads);
                //ThreadPool.SetMaxThreads(threads, 4000);

                //ThreadPool.GetMinThreads(out threads, out iothreads);
                //ThreadPool.SetMinThreads(4000, 4000);

                //DedicatedThreadPool threadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount));
                var threadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(4000));

                var emulator = new Emulator {
                    Running = true
                };
                long start = DateTime.UtcNow.Ticks;

                //IPEndPoint endPoint = new IPEndPoint(Dns.GetHostEntry("yodamine.com").AddressList[0], 19132);
                var endPoint = new IPEndPoint(IPAddress.Loopback, 19132);

                Task.Run(() =>
                {
                    var sw = Stopwatch.StartNew();
                    for (int j = 0; j < NumberOfBots; j++)
                    {
                        string playerName = $"TheGrey{j + 1:D3}";

                        var client = new ClientEmulator(threadPool,
                                                        emulator,
                                                        DurationOfConnection,
                                                        playerName,
                                                        (int)(DateTime.UtcNow.Ticks - start),
                                                        endPoint,
                                                        RanSleepMin,
                                                        RanSleepMax,
                                                        RequestChunkRadius);

                        new Thread(o => { client.EmulateClient(); })
                        {
                            IsBackground = true
                        }.Start();

                        if (ConcurrentSpawn)
                        {
                            if (j % ConcurrentBatchSize == 0 && j != 0)
                            {
                                for (int i = 0; i < ConcurrentBatchSize; i++)
                                {
                                    emulator.ConcurrentSpawnWaitHandle.WaitOne(TimeSpan.FromMilliseconds(1000));
                                }
                            }

                            continue;
                        }

                        emulator.ConcurrentSpawnWaitHandle.WaitOne();

                        long elapsed = sw.ElapsedMilliseconds;
                        if (elapsed < TimeBetweenSpawns)
                        {
                            Thread.Sleep((int)(TimeBetweenSpawns - elapsed));
                        }

                        sw.Restart();
                    }
                });

                Console.WriteLine("Press <enter> to stop all clients.");
                Console.ReadLine();
                emulator.Running = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                Console.ResetColor();
            }

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }