Exemple #1
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>();
 }
Exemple #2
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();
 }
Exemple #3
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();
 }
Exemple #4
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();
 }
Exemple #5
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            mClient = new XRPCClient("localhost", 9090);
            mClient.Options.ParameterFormater = new JsonPacket();
            mClient.AddDelegate <Action <DateTime> >(SetTime);
            comboEmployees.ItemsSource = from a in await mClient.Delegate <ListEmployees>()() select new { a.EmployeeID, Name = $"{a.FirstName} {a.LastName}" };
            comboxCustomer.ItemsSource = await mClient.Delegate <ListCustomers>()();

            lstOrders.ItemsSource = await mClient.Delegate <ListOrders>()(0, null);
        }
        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);
        }
Exemple #7
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;
     Test();
     Console.Read();
 }
Exemple #8
0
 static void Main(string[] args)
 {
     client = new XRPCClient("127.0.0.1", 9090);
     client.Connect();
     client.NetError = (c, e) =>
     {
         Console.WriteLine(e.Error.Message);
     };
     client.TimeOut = 10000;
     Hello();
     System.Threading.Thread.Sleep(-1);
 }
Exemple #9
0
 static void Main(string[] args)
 {
     client = new XRPCClient("192.168.2.18", 9090, 2);
     client.Connect();
     client.NetError = (c, e) =>
     {
         Console.WriteLine(e.Error.Message);
     };
     client.TimeOut = 10000;
     UserService    = client.Create <IUserService>();
     Test();
     Console.Read();
 }
        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();
        }
        static void Main(string[] args)
        {
            client = new XRPCClient("192.168.1.18", 9090);
            //client.PingTimeout = 5;
            client.Options.ParameterFormater = new JsonPacket();

            client.TimeOut = 100000;
            //  TestTaskResultDelegate(client);
            //UnitTest();
            var task = client.Subscribe <Action <DateTime> >(d =>
            {
                Console.WriteLine(d);
            });

            System.Threading.Thread.Sleep(-1);
        }
Exemple #12
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> > >();
 }
Exemple #13
0
        /// <summary>
        /// 注册XRPC服务
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddXRPCClient(this IServiceCollection services, IConfiguration configuration)
        {
            var hosts   = configuration.GetSection("XRPCClient").Value;
            var timeOut = configuration.GetSection("XRPCClientTimeOut").Value;
            var arr     = hosts.Split(";").ToList();
            KetamaNodeLocator ketamaNodeLocator = new KetamaNodeLocator(arr);
            var host = ketamaNodeLocator.GetPrimary(Guid.NewGuid().ToString());

            var client = new XRPCClient(host.Split(":")[0], Convert.ToInt32(host.Split(":")[1]));

            client.TimeOut = Convert.ToInt32(timeOut);
            client.Connect();
            client.NetError = (c, e) =>
            {
                Console.WriteLine(e.Error.Message);
            };

            services.AddSingleton(client);
            return(services);
        }
Exemple #14
0
        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();
        }
Exemple #15
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;
            }
        }
Exemple #16
0
 static XRPCHandler()
 {
     Client = new XRPCClient(Setting.SERVER_HOST, 50052, 3);
     Client.Connect();
     Greeter = Client.Create <XRPCModule.IGreeter>();
 }
Exemple #17
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     XRPCClient = new XRPCClient("localhost", 9090);
     XRPCClient.Options.ParameterFormater = new JsonPacket();
     dataService = XRPCClient.Create <IDataService>();
 }
Exemple #18
0
 public XRPCHandler()
 {
     Client = new XRPCClient("192.168.2.19", 50052, 3);
     Client.Connect();
     Greeter = Client.Create <XRPCModule.IGreeter>();
 }
Exemple #19
0
 public XRPCHandler()
 {
     Client = new XRPCClient("192.168.2.19", 9013, 3);
     Client.Connect();
     UserService = Client.Create <IUserService>();
 }