Example #1
0
        static void Main()
        {
            Console.WriteLine("All test:");
            Console.WriteLine("1 PureUdp test");
            Console.WriteLine("2 PureKcp test");
            Console.WriteLine("3 Udp+Kcp mix test");
            Console.WriteLine("other: exit");
            string input = "";

            Console.WriteLine("input 1~3:");
            input = Console.ReadLine();
            switch (input.Trim())
            {
            case "0":
                StartServer = StartServer0;
                break;

            case "1":
                StartServer = StartServer1;
                break;

            case "2":
                StartServer = StartServer2;
                break;

            case "3":
                StartServer = StartServer3;
                break;

            default:
                return;

                break;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new ServerForm1());
            var servertype = Server.GetType().Name;
            var t          = Server.AsyncClose(TimeSpan.FromSeconds(10));

            Console.WriteLine("closing..");
            t.Wait();
            Console.WriteLine($"Server {servertype} Closed. Press any to to exit");
            Console.ReadKey();
        }
Example #2
0
        static void Main()
        {
            //sw.Start();
            //lasttime = DateTime.Now;
            //System.Threading.SpinWait wait = new System.Threading.SpinWait();
            //for (int i = 0; i < 100000; i++)
            //{
            //    if (DateTime.Now.Subtract(lasttime).TotalMilliseconds > 1000)
            //    {
            //        lasttime = DateTime.Now;
            //        Console.WriteLine($"{sw.ElapsedMilliseconds}\t {counter - counter2}\t {counter}");
            //        counter2 = counter;
            //    }
            //    wait.SpinOnce();
            //    counter++;
            //}
            Console.WriteLine("All test:");
            Console.WriteLine("1 PureUdp test");
            Console.WriteLine("2 PureKcp test");
            Console.WriteLine("3 Udp+Kcp mix test");
            Console.WriteLine("4 PureKcp withflush minrto test");
            Console.WriteLine("other: exit");
            string input = "";

            Console.WriteLine("input 1~4:");
            input = Console.ReadLine();
            switch (input.Trim())
            {
            case "0":
                StartServer = StartServer0;
                break;

            case "1":
                StartServer = StartServer1;
                break;

            case "2":
                StartServer = StartServer2;
                break;

            case "3":
                StartServer = StartServer3;
                break;

            case "4":
                StartServer = StartServer4;
                break;

            default:
                return;

                break;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new ServerForm1());
            var servertype = Server.GetType().Name;
            var t          = Server.AsyncClose(TimeSpan.FromSeconds(10));

            Console.WriteLine("closing..");
            t.Wait();
            Console.WriteLine($"Server {servertype} Closed. Press any to to exit");
            Console.ReadKey();
        }