Exemplo n.º 1
0
        public void EmulateClient()
        {
            try
            {
                int threads;
                int iothreads;
                ThreadPool.GetAvailableThreads(out threads, out iothreads);

                Console.WriteLine($"Client {Name} connecting...");

                var client = new MiNetClient(EndPoint, Name, _threadPool);
                client.ChunkRadius = ChunkRadius;
                client.IsEmulator  = true;
                client.ClientId    = ClientId;

                client.StartClient();
                Console.WriteLine("Client started.");

                client.HaveServer = true;
                client.SendOpenConnectionRequest1();

                //client.FirstPacketWaitHandle.WaitOne();
                //client.FirstEncryptedPacketWaitHandle.WaitOne();
                client.PlayerStatusChangedWaitHandle.WaitOne();
                Emulator.ConcurrentSpawnWaitHandle.Set();
                Console.CursorLeft = Console.CursorLeft = Console.BufferWidth - $"Client {Name} connected, emulating...".Length;
                if (client.UdpClient != null)
                {
                    Console.WriteLine($"Client {Name} connected, emulating...");
                }

                Stopwatch watch = new Stopwatch();
                watch.Start();

                //Thread.Sleep(3000);

                //client.SendChat(".tp test");
                //client.SendChat("/join bb");
                //client.SendChat("/join skywars");

                //Thread.Sleep(TimeToRun);

                //if (client.CurrentLocation != null)
                //{
                //	client.CurrentLocation = new PlayerLocation(client.CurrentLocation.X, -10, client.CurrentLocation.Z);
                //	client.SendMcpeMovePlayer();
                //	Thread.Sleep(3000);
                //}

                //client.SendChat("/hub");

                //Thread.Sleep(3000);

                for (int i = 0; /*i < 10 && */ Emulator.Running && watch.Elapsed < TimeToRun; i++)
                {
                    if (client.UdpClient == null)
                    {
                        break;
                    }

                    float y      = client.Level.SpawnX + Random.Next(7, 10) + /*24*/ 75;
                    float length = Random.Next(5, 20);

                    double       angle          = 0.0;
                    const double angleStepsize  = 0.05;
                    float        heightStepsize = (float)(Random.NextDouble() / 5);

                    while (angle < 2 * Math.PI && Emulator.Running)
                    {
                        if (client.UdpClient == null)
                        {
                            break;
                        }

                        float x = (float)(length * Math.Cos(angle));
                        float z = (float)(length * Math.Sin(angle));
                        y += heightStepsize;

                        x += client.Level.SpawnX;
                        z += client.Level.SpawnZ;

                        client.CurrentLocation = new PlayerLocation(x, y, z);
                        client.SendMcpeMovePlayer();

                        int timeout;
                        if (RanMax == RanMax)
                        {
                            timeout = RanMin;
                        }
                        else
                        {
                            timeout = Random.Next(RanMin, RanMax);
                        }

                        if (timeout > 0)
                        {
                            Thread.Sleep(timeout);
                        }
                        angle += angleStepsize;
                    }
                }

                if (client.UdpClient != null)
                {
                    client.SendChat("Shadow gov agent BREXITING!");
                    client.SendDisconnectionNotification();
                }

                client.StopClient();
                Console.WriteLine($"{watch.ElapsedMilliseconds} Client stopped. {client.UdpClient == null}, {Emulator.Running}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 2
0
        public void EmulateClient()
        {
            try
            {
                Console.WriteLine($"Client {Name} connecting...");

                var client = new MiNetClient(EndPoint, Name, _threadPool);
                client.ChunkRadius = ChunkRadius;
                client.IsEmulator  = true;
                client.ClientId    = ClientId;

                client.StartClient();
                client.Connection.ConnectionInfo.DisableAck = true;
                Console.WriteLine("Client started.");

                client.SendOpenConnectionRequest1();

                //client.FirstPacketWaitHandle.WaitOne();
                //client.FirstEncryptedPacketWaitHandle.WaitOne();
                client.PlayerStatusChangedWaitHandle.WaitOne();
                client.Connection.ConnectionInfo.IsEmulator = true;
                Emulator.ConcurrentSpawnWaitHandle.Set();
                Console.CursorLeft = Console.CursorLeft = Console.BufferWidth - $"Client {Name} connected, emulating...".Length;
                Console.WriteLine($"Client {Name} connected, emulating...");

                var runningTime = Stopwatch.StartNew();

                //Thread.Sleep(3000);

                //client.SendChat(".tp test");
                //client.SendChat("/join bb");
                //client.SendChat("/join skywars");

                //Thread.Sleep(TimeToRun);

                //if (client.CurrentLocation != null)
                //{
                //	client.CurrentLocation = new PlayerLocation(client.CurrentLocation.X, -10, client.CurrentLocation.Z);
                //	client.SendMcpeMovePlayer();
                //	Thread.Sleep(3000);
                //}

                //client.SendChat("/hub");

                //Thread.Sleep(3000);

                for (int i = 0; /*i < 10 && */ Emulator.Running && runningTime.Elapsed < TimeToRun; i++)
                {
                    if (!client.IsConnected)
                    {
                        break;
                    }

                    float y      = client.LevelInfo.SpawnX + Random.Next(7, 10);
                    float length = Random.Next(5, 20);

                    double       angle          = 0.0;
                    const double angleStepsize  = 0.05;
                    float        heightStepSize = (float)(Random.NextDouble() / 5);

                    while (angle < 2 * Math.PI && Emulator.Running)
                    {
                        if (!client.IsConnected)
                        {
                            break;
                        }

                        float x = (float)(length * Math.Cos(angle));
                        float z = (float)(length * Math.Sin(angle));
                        y += heightStepSize;

                        x += client.LevelInfo.SpawnX;
                        z += client.LevelInfo.SpawnZ;

                        client.CurrentLocation = new PlayerLocation(x, y, z, (float)angle.ToDegrees(), (float)angle.ToDegrees());
                        //client.SendMcpeMovePlayer();
                        client.SendCurrentPlayerPositionAsync().Wait();

                        int timeout = RanMin == RanMax ? RanMin : Random.Next(RanMin, RanMax);
                        if (timeout > 0)
                        {
                            Thread.Sleep(timeout);
                        }

                        angle += angleStepsize;
                    }
                }

                if (client.IsConnected)
                {
                    client.SendChat("Shadow gov agent BREXITING!");
                    client.SendDisconnectionNotification();
                }

                client.StopClient();
                Console.WriteLine($"{runningTime.ElapsedMilliseconds} Client stopped. {client.IsConnected}, {Emulator.Running}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 3
0
        public void EmulateClient()
        {
            try
            {
                Console.WriteLine("Client {0} connecting...", Name);

                //var client = new MiNetClient(new IPEndPoint(Dns.GetHostEntry("play.lbsg.net").AddressList[0], 19132), new IPEndPoint(IPAddress.Any, 0));
                //var client = new MiNetClient(new IPEndPoint(Dns.GetHostEntry("test.inpvp.net").AddressList[0], 19132), new IPEndPoint(IPAddress.Any, 0));
                //var client = new MiNetClient(new IPEndPoint(IPAddress.Parse("46.7.101.176"), 19132), Name);
                var client = new MiNetClient(new IPEndPoint(IPAddress.Loopback, 19134), Name);
                client.IsEmulator = true;
                client.ClientId   = ClientId;

                client.StartClient();
                Console.WriteLine("Client started.");

                client.HaveServer = true;
                client.SendOpenConnectionRequest1();

                Thread.Sleep(2000);

                client.LoginSent = true;

                Stopwatch watch = new Stopwatch();
                watch.Start();
                if (client.UdpClient != null)
                {
                    Console.WriteLine("\t\t\t\t\t\tClient {0} moving...", Name);
                }

                for (int i = 0; /*i < 10 && */ Emulator.Running && watch.ElapsedMilliseconds < TimeToRun; i++)
                {
                    if (client.UdpClient == null)
                    {
                        break;
                    }

                    float y      = Random.Next(7, 10) + /*24*/ 55;
                    float length = Random.Next(5, 20);

                    double       angle          = 0.0;
                    const double angleStepsize  = 0.05;
                    float        heightStepsize = (float)(Random.NextDouble() / 5);

                    while (angle < 2 * Math.PI && Emulator.Running)
                    {
                        if (client.UdpClient == null)
                        {
                            break;
                        }

                        float x = (float)(length * Math.Cos(angle));
                        float z = (float)(length * Math.Sin(angle));
                        y += heightStepsize;

                        x += client.Level.SpawnX;
                        z += client.Level.SpawnZ;

                        client.CurrentLocation = new PlayerLocation(x, y, z);
                        client.SendMcpeMovePlayer();
                        Thread.Sleep(50);
                        //Thread.Sleep(Random.Next(150, 450));
                        angle += angleStepsize;
                    }
                }

                if (client.UdpClient != null)
                {
                    Console.WriteLine($"{watch.ElapsedMilliseconds} Client stopping. {client.UdpClient == null}, {Emulator.Running}");
                    client.SendDisconnectionNotification();
                }

                client.StopClient();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 4
0
        public void EmulateClient()
        {
            try
            {
                Console.WriteLine("Client {0} connecting...", Name);

                var client = new MiNetClient(EndPoint, Name);
                client.ChunkRadius = ChunkRadius;
                client.IsEmulator  = true;
                client.ClientId    = ClientId;

                client.StartClient();
                Console.WriteLine("Client started.");

                client.HaveServer = true;
                client.SendOpenConnectionRequest1();

                Thread.Sleep(2000);

                client.LoginSent = true;

                Stopwatch watch = new Stopwatch();
                watch.Start();
                if (client.UdpClient != null)
                {
                    Console.WriteLine("\t\t\t\t\t\tClient {0} moving...", Name);
                }

                for (int i = 0; /*i < 10 && */ Emulator.Running && watch.ElapsedMilliseconds < TimeToRun; i++)
                {
                    if (client.UdpClient == null)
                    {
                        break;
                    }

                    float y      = Random.Next(7, 10) + /*24*/ 55;
                    float length = Random.Next(5, 20);

                    double       angle          = 0.0;
                    const double angleStepsize  = 0.05;
                    float        heightStepsize = (float)(Random.NextDouble() / 5);

                    while (angle < 2 * Math.PI && Emulator.Running)
                    {
                        if (client.UdpClient == null)
                        {
                            break;
                        }

                        float x = (float)(length * Math.Cos(angle));
                        float z = (float)(length * Math.Sin(angle));
                        y += heightStepsize;

                        x += client.Level.SpawnX;
                        z += client.Level.SpawnZ;

                        client.CurrentLocation = new PlayerLocation(x, y, z);
                        client.SendMcpeMovePlayer();
                        Thread.Sleep(Random.Next(RanMin, RanMax));
                        angle += angleStepsize;
                    }
                }

                if (client.UdpClient != null)
                {
                    Console.WriteLine($"{watch.ElapsedMilliseconds} Client stopping. {client.UdpClient == null}, {Emulator.Running}");
                    client.SendDisconnectionNotification();
                }

                client.StopClient();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 5
0
        private void EmulateClient(object state)
        {
            try
            {
                string username = (string)state;
                Console.WriteLine("Client {0} connecting...", username);

                IPHostEntry Host = Dns.GetHostEntry("test.inpvp.net");

                //var client = new MiNetClient(new IPEndPoint(Host.AddressList[0], 19132));
                var client = new MiNetClient(new IPEndPoint(IPAddress.Loopback, 19132));
                //var client = new MiNetClient(new IPEndPoint(IPAddress.Parse("65.52.75.30"), 19132));

                client.StartClient();

                client.SendUnconnectedPing();
                Thread.Sleep(100);                 // Let the server process
                //Thread.Yield();

                client.SendOpenConnectionRequest1();
                Thread.Sleep(100);                 // Let the server process
                //Thread.Yield();

                client.SendOpenConnectionRequest2();
                Thread.Sleep(100);                 // Let the server process
                //Thread.Yield();

                client.SendConnectionRequest();
                Thread.Sleep(100);                 // Let the server process
                //Thread.Yield();

                client.SendLogin(username);
                Thread.Sleep(100);                 // Let the server process
                //Thread.Yield();

                //Console.WriteLine("\t\tClient {0} connected, sleeping 10s...", username);

                Thread.Sleep(20000);

                Console.WriteLine("\t\t\t\t\t\tClient {0} moving...", username);

                Random random = new Random();
                for (int i = 0; i < 100; i++)
                {
                    float        y = random.Next(7, 10) + /*24*/ 30;
                    float        x, z;
                    float        length         = random.Next(5, 20);
                    double       angle          = 0.0;
                    const double angleStepsize  = 0.05;
                    float        heightStepsize = (float)(random.NextDouble() / 5);

                    while (angle < 2 * Math.PI && _running)
                    {
                        x  = (float)(length * Math.Cos(angle));
                        z  = (float)(length * Math.Sin(angle));
                        y += heightStepsize;

                        x += -421;
                        z += -1633;

                        client.SendMcpeMovePlayer(x, y, z);
                        Thread.Sleep(random.Next(50, 300));
                        angle += angleStepsize;
                    }
                }

                client.SendDisconnectionNotification();
                Thread.Sleep(100);                 // Let the server process
                //Thread.Yield();

                client.StopClient();

                Console.WriteLine("Clients {0} disconnected.", username);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 6
0
        private void EmulateClient(object state)
        {
            try
            {
                string username = (string) state;
                Console.WriteLine("Client {0} connecting...", username);

                IPHostEntry Host = Dns.GetHostEntry("test.inpvp.net");

                //var client = new MiNetClient(new IPEndPoint(Host.AddressList[0], 19132));
                var client = new MiNetClient(new IPEndPoint(IPAddress.Loopback, 19132));
                //var client = new MiNetClient(new IPEndPoint(IPAddress.Parse("65.52.75.30"), 19132));

                client.StartClient();

                client.SendUnconnectedPing();
                Thread.Sleep(100); // Let the server process
                //Thread.Yield();

                client.SendOpenConnectionRequest1();
                Thread.Sleep(100); // Let the server process
                //Thread.Yield();

                client.SendOpenConnectionRequest2();
                Thread.Sleep(100); // Let the server process
                //Thread.Yield();

                client.SendConnectionRequest();
                Thread.Sleep(100); // Let the server process
                //Thread.Yield();

                client.SendLogin(username);
                Thread.Sleep(100); // Let the server process
                //Thread.Yield();

                //Console.WriteLine("\t\tClient {0} connected, sleeping 10s...", username);

                Thread.Sleep(20000);

                Console.WriteLine("\t\t\t\t\t\tClient {0} moving...", username);

                Random random = new Random();
                for (int i = 0; i < 100; i++)
                {
                    float y = random.Next(7, 10) + /*24*/30;
                    float x, z;
                    float length = random.Next(5, 20);
                    double angle = 0.0;
                    const double angleStepsize = 0.05;
                    float heightStepsize = (float) (random.NextDouble()/5);

                    while (angle < 2*Math.PI && _running)
                    {
                        x = (float) (length*Math.Cos(angle));
                        z = (float) (length*Math.Sin(angle));
                        y += heightStepsize;

                        x += -421;
                        z += -1633;

                        client.SendMcpeMovePlayer(x, y, z);
                        Thread.Sleep(random.Next(50, 300));
                        angle += angleStepsize;
                    }
                }

                client.SendDisconnectionNotification();
                Thread.Sleep(100); // Let the server process
                //Thread.Yield();

                client.StopClient();

                Console.WriteLine("Clients {0} disconnected.", username);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }