예제 #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);
 }
예제 #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();
 }
예제 #3
0
파일: Program.cs 프로젝트: longgang/XRPC
 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();
 }
예제 #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);
        }
예제 #5
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();
        }
예제 #6
0
 static XRPCHandler()
 {
     Client = new XRPCClient(Setting.SERVER_HOST, 50052, 3);
     Client.Connect();
     Greeter = Client.Create <XRPCModule.IGreeter>();
 }
예제 #7
0
 public XRPCHandler()
 {
     Client = new XRPCClient("192.168.2.19", 9013, 3);
     Client.Connect();
     UserService = Client.Create <IUserService>();
 }
예제 #8
0
 public XRPCHandler()
 {
     Client = new XRPCClient("192.168.2.19", 50052, 3);
     Client.Connect();
     Greeter = Client.Create <XRPCModule.IGreeter>();
 }