public static Tuple <JRpcService, T> StartService <T>(string serviceName, JRpcModule jRpcModule, string ipAdress = null, string port = null) where T : class { if (string.IsNullOrEmpty(ipAdress)) { ipAdress = DEFAULT_IP_ADRESS; } if (string.IsNullOrEmpty(port)) { port = DEFAULT_PORT; } ConfigurationManager.AppSettings.Set("ServiceAddress", ipAdress); ConfigurationManager.AppSettings.Set("ServicePort", port); var consulClient = new ConsulClient(); var registry = new DefaultModulesRegistry(); registry.AddJRpcModule(jRpcModule); var service = new JRpcService(registry, consulClient); service.Start(); var path = $"http://{ipAdress}:{port}"; var client = new JRpcClient(path); var clientProxy = client.GetProxy <T>(serviceName); return(Tuple.Create(service, clientProxy)); }
static void Main(string[] args) { var defaultModulesRegistry = new DefaultModulesRegistry(); defaultModulesRegistry.AddJRpcModule(new NewTestService()); var service = new JRpcService(defaultModulesRegistry, new ConsulClient(), new KestrelJRpcServerHost()); service.Start(); Console.WriteLine("Hello World!"); Console.ReadLine(); }
static void Main(string[] args) { var client = new ConsulClient(); var registry = new DefaultModulesRegistry(); registry.AddJRpcModule(new SimpleService()); var svc = new JRpcService(registry, client, new OwinJrpcServer()); svc.Start(); Console.ReadLine(); svc.Stop(); }