Example #1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            LogAction.LogOut      += LogAction_LogOut;
            CloudClient client = new CloudClient(new SocketClient(), 500000, 1024 * 1024); //最大数据包能够接收 1M
            PackHander  tmp    = new PackHander();

            client.Install(tmp);
            client.Disconnect += Client_Disconnect;

            if (client.Connect("127.0.0.1", 2285))
            {
                ZYSync Sync = client.Sync;

                var res = Sync.CR(1000, "AAA", "BBB")?[0]?.Value <bool>();

                if (res != null && res == true)
                {
                    var html = Sync.CR(2001, "http://www.baidu.com")?[0]?.Value <string>();
                    if (html != null)
                    {
                        Console.WriteLine("BaiduHtml:" + html.Length);

                        var time = Sync.CR(2002)?.First?.Value <DateTime>();

                        Console.WriteLine("ServerTime:" + time);

                        Sync.CV(2003, "123123");

                        var x = Sync.CR(2001, "http://www.qq.com");

                        Console.WriteLine("QQHtml:" + x.First.Value <string>().Length);

                        System.Diagnostics.Stopwatch stop = new System.Diagnostics.Stopwatch();
                        stop.Start();
                        var rec = Sync.CR(2500, 1000)?.First?.Value <int>();
                        stop.Stop();
                        if (rec != null)
                        {
                            Console.WriteLine("Rec:{0} time:{1} MS", rec.Value, stop.ElapsedMilliseconds);
                        }

                        TestRun(client);
                    }
                }

                Console.WriteLine("Close");

                Console.ReadLine();
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;


            CloudClient client = new ClientBuilder().Bulid();
            PackHander  tmp    = new PackHander();

            client.Install(tmp);
            client.Disconnect += Client_Disconnect;


            if (client.Init("127.0.0.1", 2285))
            {
                IPacker ServerPack = client.GetForEmit <IPacker>();
re:
                try
                {
                    var res = ServerPack.IsLogOn("AAA", "BBB")?[0]?.Value <bool>();

                    if (res != null && res == true)
                    {
                        var html = ServerPack.StartDown("http://www.baidu.com");



                        if (html != null)
                        {
                            Console.WriteLine("BaiduHtml:" + html.Length);


                            var time = ServerPack.GetTime();


                            ServerPack.ShowMessage("ff");


                            Console.WriteLine("ServerTime:" + time);

                            ServerPack.SetPassWord("123123");

                            var x = ServerPack.StartDown("http://www.qq.com");

                            Console.WriteLine("QQHtml:" + x.Length);

                            System.Diagnostics.Stopwatch stop = new System.Diagnostics.Stopwatch();
                            stop.Start();
                            var rec = ServerPack.TestRec(10000);
                            stop.Stop();

                            Console.WriteLine("Rec1:{0} time:{1} MS", rec, stop.ElapsedMilliseconds);


                            stop.Restart();
                            rec = ServerPack.TestRec(10000);
                            stop.Stop();
                            Console.WriteLine("Rec1:{0} time:{1} MS", rec, stop.ElapsedMilliseconds);

                            stop.Restart();
                            rec = ServerPack.TestRec(10000);
                            stop.Stop();
                            Console.WriteLine("Rec1:{0} time:{1} MS", rec, stop.ElapsedMilliseconds);

                            Console.WriteLine();
                            stop.Restart();
                            rec = ServerPack.TestRec2(10000);
                            stop.Stop();
                            Console.WriteLine("Rec2:{0} time:{1} MS", rec, stop.ElapsedMilliseconds);

                            stop.Restart();
                            rec = ServerPack.TestRec2(10000);
                            stop.Stop();
                            Console.WriteLine("Rec2:{0} time:{1} MS", rec, stop.ElapsedMilliseconds);

                            stop.Restart();
                            rec = ServerPack.TestRec2(10000);
                            stop.Stop();
                            Console.WriteLine("Rec2:{0} time:{1} MS", rec, stop.ElapsedMilliseconds);


                            TestRun(client);
                        }
                    }
                }
                catch (TimeoutException er)
                {
                    Console.WriteLine(er.ToString());
                }

                Console.WriteLine("Close");
                Console.ReadLine();

                goto re;
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            CloudClient client = new ClientBuilder().Bulid();
            PackHander  tmp    = new PackHander();

            client.Install(tmp);
            client.Disconnect += Client_Disconnect;

            if (client.Init("127.0.0.1", 2285))
            {
                IPacker ServerPack = client.Get <IPacker>();


                //re:
                try
                {
                    var res = ServerPack.IsLogOn("AAA", "BBB")?[0]?.Value <bool>();

                    if (res != null && res == true)
                    {
                        var html = ServerPack.StartDown("http://www.baidu.com")?[0]?.Value <string>();
                        if (html != null)
                        {
                            Console.WriteLine("BaiduHtml:" + html.Length);

                            var time = ServerPack.GetTime();

                            Console.WriteLine("ServerTime:" + time);

                            ServerPack.SetPassWord("123123");

                            string cc = ServerPack.SetMessage("HEIIO", "WORD");
                            Console.WriteLine(cc);

                            ServerPack.SetMessage();

                            var x = ServerPack.StartDown("http://www.qq.com");

                            Console.WriteLine("QQHtml:" + x.First.Value <string>().Length);

                            System.Diagnostics.Stopwatch stop = new System.Diagnostics.Stopwatch();
                            stop.Start();
                            var rec = ServerPack.TestRec2(10000);
                            stop.Stop();
                            Console.WriteLine("Rec:{0} time:{1} MS", rec, stop.ElapsedMilliseconds);
                            stop.Restart();
                            rec = ServerPack.TestRec2(10000);
                            stop.Stop();
                            Console.WriteLine("Rec:{0} time:{1} MS", rec, stop.ElapsedMilliseconds);
                            stop.Restart();
                            rec = ServerPack.TestRec2(10000);
                            stop.Stop();
                            Console.WriteLine("Rec:{0} time:{1} MS", rec, stop.ElapsedMilliseconds);

                            stop.Restart();

                            long cf = 0;
                            while (cf < 100000)
                            {
                                cf = ServerPack.Adds(cf);
                            }

                            stop.Stop();
                            Console.WriteLine("ADD:{0} time:{1} MS", cf, stop.ElapsedMilliseconds);

                            stop.Restart();
                            for (int j = 0; j < 100000; j++)
                            {
                                ServerPack.Add(10);
                                ServerPack.Sub(5);
                            }

                            int i = ServerPack.GitIt();

                            stop.Stop();



                            Console.WriteLine("ADD:{0} time:{1} MS", i, stop.ElapsedMilliseconds);


                            stop.Restart();

                            Parallel.For(0, 100000, (xxxx) =>
                            {
                                ServerPack.Add(10);
                            });

                            i = ServerPack.GitIt();

                            stop.Stop();



                            Console.WriteLine("ADDASYN:{0} time:{1} MS", i, stop.ElapsedMilliseconds);

                            stop.Restart();
                            Parallel.For(0, 100000, (num) =>
                            {
                                long a = ServerPack.AddRet(num);
                            });

                            stop.Stop();

                            var l = ServerPack.Gitnum();
                            Console.WriteLine("AddRetASYN:{0} time:{1} MS", l, stop.ElapsedMilliseconds);

                            TestRun(client);
                            //TestRun(client);
                            //TestRun(client);
                        }
                    }
                }
                catch (TimeoutException er)
                {
                    Console.WriteLine(er.ToString());
                }

                Console.WriteLine("Close");
                Console.ReadLine();
            }
        }