Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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();
 }
Ejemplo n.º 3
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();
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
 static XRPCHandler()
 {
     Client = new XRPCClient(Setting.SERVER_HOST, 50052, 3);
     Client.Connect();
     Greeter = Client.Create <XRPCModule.IGreeter>();
 }
Ejemplo n.º 7
0
 public XRPCHandler()
 {
     Client = new XRPCClient("192.168.2.19", 9013, 3);
     Client.Connect();
     UserService = Client.Create <IUserService>();
 }
Ejemplo n.º 8
0
 public XRPCHandler()
 {
     Client = new XRPCClient("192.168.2.19", 50052, 3);
     Client.Connect();
     Greeter = Client.Create <XRPCModule.IGreeter>();
 }