예제 #1
0
 static void Main(string[] args)
 {
     client = new XRPCClient("localhost", 9090);
     client.Options.ParameterFormater = new JsonPacket();//default messagepack
     henry = client.Create <IAmount>("henry");
     ken   = client.Create <IAmount>("ken");
     Test();
     Console.Read();
 }
예제 #2
0
파일: Program.cs 프로젝트: longgang/XRPC
        static async void Test(int concurrent, int requests)
        {
            mCount = 0;
            IAmountService henry = client.Create <IAmountService>("henry");
            IAmountService ken   = client.Create <IAmountService>("ken");

            Console.WriteLine($"[C:{concurrent}|R:{requests}]Testing ");
            List <Task> tasks = new List <Task>();
            double      start = BeetleX.TimeWatch.GetElapsedMilliseconds();

            for (int i = 0; i < concurrent; i++)
            {
                var task = Task.Run(async() =>
                {
                    for (int k = 0; k < requests; k++)
                    {
                        await henry.Income(10);
                        System.Threading.Interlocked.Increment(ref mCount);
                    }
                });
                tasks.Add(task);
                task = Task.Run(async() =>
                {
                    for (int k = 0; k < requests; k++)
                    {
                        await henry.Payout(10);
                        System.Threading.Interlocked.Increment(ref mCount);
                    }
                });
                tasks.Add(task);
                task = Task.Run(async() =>
                {
                    for (int k = 0; k < requests; k++)
                    {
                        await ken.Income(10);
                        System.Threading.Interlocked.Increment(ref mCount);
                    }
                });
                tasks.Add(task);
                task = Task.Run(async() =>
                {
                    for (int k = 0; k < requests; k++)
                    {
                        await ken.Payout(10);
                        System.Threading.Interlocked.Increment(ref mCount);
                    }
                });
                tasks.Add(task);
            }
            await Task.WhenAll(tasks.ToArray());

            double useTime = BeetleX.TimeWatch.GetElapsedMilliseconds() - start;

            Console.WriteLine($"Completed count:{mCount}|use time:{useTime}|rps:{(mCount / useTime * 1000d):###.00} |henry:{await henry.Get()},ken:{await ken.Get()}");
        }
예제 #3
0
        static async void Test()
        {
            var api     = client.Create <IUserService>();
            var lresult = await api.Login("admin", "123456");

            Console.WriteLine(lresult);
            var result = await api.Add("henry", "*****@*****.**", "gz", "http://github.com");

            Console.WriteLine($"{result.Name}\t{result.EMail}\t{result.City}\t{result.Remark}");
            await api.Save();

            Console.WriteLine("save completed");
            User user = new User();

            user.ID     = Guid.NewGuid().ToString("N");
            user.Name   = "henry";
            user.EMail  = "*****@*****.**";
            user.City   = "GuangZhou";
            user.Remark = "http://github.com/ikende";
            result      = await api.Modify(user);

            Console.WriteLine($"{result.Name}\t{result.EMail}\t{result.City}\t{result.Remark}");
            var items = await api.List(5);

            foreach (var item in items)
            {
                Console.WriteLine($"{item.Name}\t{item.EMail}\t{item.City}\t{item.Remark}");
            }
        }
예제 #4
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     XRPCClient = new XRPCClient("localhost", 9090, "test");
     XRPCClient.CertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true;
     XRPCClient.Options.ParameterFormater     = new JsonPacket();
     dataService = XRPCClient.Create <IDataService>();
 }
예제 #5
0
 static void Main(string[] args)
 {
     client = new XRPCClient("localhost", 9090);
     client.Options.ParameterFormater = new JsonPacket();//default messagepack
     dataService = client.Create <IDataService>();
     Test();
     Console.Read();
 }
예제 #6
0
 static void Main(string[] args)
 {
     client = new XRPCClient("localhost", 9090, "test");
     client.CertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true;
     client.Options.ParameterFormater     = new JsonPacket();//default messagepack
     dataService = client.Create <IDataService>();
     Test();
     Console.Read();
 }
예제 #7
0
        static void Main(string[] args)
        {
            client          = new XRPCClient("192.168.2.18", 9090);
            client.PingTime = 5;
            client.Options.ParameterFormater = new JsonPacket();
            client.Register <IUser>(new Program());
            var user = client.Create <IUser>();

            user.Login("henry");
            System.Threading.Thread.Sleep(-1);
        }
예제 #8
0
 static void Main(string[] args)
 {
     client = new XRPCClient("localhost", 9090);
     client.Connect();
     client.NetError = (c, e) =>
     {
         Console.WriteLine(e.Error.Message);
     };
     client.TimeOut = 10000;
     UserService    = client.Create <IUserService>();
     Test();
     Console.Read();
 }
예제 #9
0
        static async void Hello()
        {
            var service = client.Create <IHelloWorld>();

            while (true)
            {
                Console.Write("enter name:");
                string name   = Console.ReadLine();
                var    result = await service.Hello(name);

                Console.WriteLine(result);
            }
        }
예제 #10
0
        static async Task Main(string[] args)
        {
            client = new XRPCClient("localhost", 9090);
            client.Options.ParameterFormater = new JsonPacket();//default messagepack
            hello = client.Create <IHello>();
            while (true)
            {
                Console.Write("Enter you name:");
                var name   = Console.ReadLine();
                var result = await hello.Hello(name);

                Console.WriteLine(result);
            }
            Console.Read();
        }
예제 #11
0
 public MainPage()
 {
     InitializeComponent();
     //定义XRPC SSL客户端
     mClient = new XRPCClient("192.168.1.18", 9090, "beetlex");
     mClient.CertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true;
     mClient.Options.ParameterFormater     = new JsonPacket();
     //创建接口远程调用代理
     mUser = mClient.Create <IUser>();
     //定义委托给服务端调用
     mClient.AddDelegate <Func <Task <string> > >(() =>
     {
         return(Task.FromResult($"{Environment.OSVersion} {DateTime.Now}"));
     });
     //创建对应服务端的远程委托代理
     mGetTime = mClient.Delegate <Func <Task <string> > >();
 }
예제 #12
0
        static void Main(string[] args)
        {
            BufferPool.BUFFER_SIZE = 1024 * 32;
            client          = new XRPCClient("192.168.2.19", 9090, 1);
            client.NetError = (c, e) =>
            {
                Console.WriteLine(e.Error.Message);
            };
            client.TimeOut = 10000;
            UserService    = client.Create <IUserService>();
            int thread = 1;

            if (args != null && args.Length > 0)
            {
                thread = int.Parse(args[0]);
            }
            Test(thread);
            while (true)
            {
                System.Threading.Thread.Sleep(1000);
                Console.WriteLine($"{DateTime.Now} {mCount:000,000,000,000}/RPS:{mCount - mLastCount:###,###,###}");
                mLastCount = mCount;
            }
        }
예제 #13
0
파일: Program.cs 프로젝트: nodyang/xrcp_di
        static async Task Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Random random = new Random();

            _client         = new XRPCClient("127.0.0.1", 9090);
            _client.TimeOut = 10000;
            _client.Connect();
            _client.NetError = (c, e) =>
            {
                Console.WriteLine(e.Error.Message);
            };
            var service = _client.Create <IHelloWorld>();

            while (true)
            {
                var result = await service.Hello();

                Console.WriteLine(result + "  " + DateTime.Now.ToString("s"));
                Thread.Sleep(random.Next(100));
            }

            Console.ReadKey();
        }
예제 #14
0
 static XRPCHandler()
 {
     Client = new XRPCClient(Setting.SERVER_HOST, 50052, 3);
     Client.Connect();
     Greeter = Client.Create <XRPCModule.IGreeter>();
 }
예제 #15
0
 public XRPCHandler()
 {
     Client = new XRPCClient("192.168.2.19", 9013, 3);
     Client.Connect();
     UserService = Client.Create <IUserService>();
 }
예제 #16
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     XRPCClient = new XRPCClient("localhost", 9090);
     XRPCClient.Options.ParameterFormater = new JsonPacket();
     dataService = XRPCClient.Create <IDataService>();
 }
예제 #17
0
 public XRPCHandler()
 {
     Client = new XRPCClient("192.168.2.19", 50052, 3);
     Client.Connect();
     Greeter = Client.Create <XRPCModule.IGreeter>();
 }