static async Task Main(string[] args) { var o = new GrpcServiceOptions(); o.AddPort("0.0.0.0", 50001); await NetRpcManager.CreateHost(o, null, new Contract <IService, Service>()).RunAsync(); }
public static ServiceProxy OpenRabbitMQService(params object[] instances) { var service = NetRpcManager.CreateServiceProxy(GetMQParam(), instances); service.Open(); return(service); }
static async Task Main(string[] args) { var p = NetRpcManager.CreateClientProxy <IService>(new GrpcClientOptions { Host = "localhost", Port = 50001 }); await p.Proxy.Call(async i => Console.WriteLine($"receive callback: {i}")); Console.Read(); }
static async Task Main(string[] args) { var host = NetRpcManager.CreateHost(Helper.GetMQOptions(), null, new Contract <IServiceAsync, ServiceAsync>()); Console.WriteLine("Service Opened."); await host.RunAsync(); Console.Read(); }
static async Task Main(string[] args) { var o = new GrpcServiceOptions(); o.AddPort("0.0.0.0", 50001); var options = new MiddlewareOptions(); options.UseCallbackThrottling(1000); var host = NetRpcManager.CreateHost(o, options, new Contract <IService, Service>()); await host.RunAsync(); }
static async Task Main(string[] args) { var p = NetRpcManager.CreateClientProxy <IService>(new GrpcClientOptions { Host = "lj", Port = 50001 }); await p.Proxy.Call("hello world."); Console.Read(); }
static async Task Main(string[] args) { //var c = NetRpcManager.CreateClientProxy<ITranslateRawService>(new GrpcClientOptions() {Url = "http://m.k8s.yx.com:34418"}); var c = NetRpcManager.CreateClientProxy <ITranslateRawService>(new GrpcClientOptions() { Url = "http://localhost:8006" }); var r = await c.Proxy.TranslateTextByEngineTypeAsync(new List <string>() { "hello" }, Guid.Empty, null, TranslateType.Chat, LanguageType.en, LanguageType.zs, null, null, default); Console.WriteLine("Hello World!"); }
static void Main(string[] args) { var proxy = NetRpcManager.CreateClientProxy <IService>(Helper.GetMQParam()).Proxy; var fileStream = File.Open(@"d:\4\1212.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); for (int i = 0; i < 10; i++) { proxy.CallAsync(fileStream, j => Console.WriteLine(j), i.ToString()); Console.WriteLine($"Send {i}"); } Console.WriteLine($"Send end"); Console.Read(); }
static async Task Main(string[] args) { _proxyAsync = NetRpcManager.CreateClientProxy <IServiceAsync>(new HttpClientOptions { SignalRHubUrl = "http://localhost:5000/callback", ApiUrl = "http://localhost:5000/api" }).Proxy; await Test_CallAsync(); await Test_CallByCancelAsync(); await Test_CallByCustomExceptionAsync(); await Test_CallByDefaultExceptionAsync(); await Test_CallByResponseTextExceptionAsync(); await Test_ComplexCallAsync(); Console.Read(); }
static async Task Main(string[] args) { //rabbitMq var mOpt = new MiddlewareOptions(); mOpt.UseMiddleware <TestGlobalExceptionMiddleware>(); var mqHost = NetRpcManager.CreateHost(Helper.GetMQOptions(), mOpt, new Contract <IService, Service>(), new Contract <IServiceAsync, ServiceAsync>()); mqHost.RunAsync(); //grpc var grpcHost = NetRpc.Grpc.NetRpcManager.CreateHost(Helper.GetGrpcServiceOptions(), null, new Contract <IService, Service>(), new Contract <IServiceAsync, ServiceAsync>()); grpcHost.RunAsync(); Console.Read(); }
static async Task Main(string[] args) { var webHost = NetRpcManager.CreateHost( 5000, "/callback", true, new HttpServiceOptions { ApiRootPath = "/api" }, null, new Contract <IServiceAsync, ServiceAsync>()); await webHost.RunAsync(); //const string origins = "_myAllowSpecificOrigins"; //var h = WebHost.CreateDefaultBuilder(null) // .ConfigureServices(services => // { // services.AddCors(op => // { // op.AddPolicy(origins, set => // { // set.SetIsOriginAllowed(origin => true) // .AllowAnyHeader() // .AllowAnyMethod() // .AllowCredentials(); // }); // }); // services.AddSignalR(); // services.AddNetRpcSwagger(); // services.AddNetRpcHttpService(i => i.ApiRootPath = "/api"); // services.AddNetRpcContractSingleton<IServiceAsync, ServiceAsync>(); // }) // .Configure(app => // { // app.UseCors(origins); // app.UseSignalR(routes => { routes.MapHub<CallbackHub>("/callback"); }); // app.UseNetRpcSwagger(); // app.UseNetRpcHttp(); // }) // .Build(); //await h.RunAsync(); }
static async Task Main(string[] args) { HttpClient c = new HttpClient(); var res = await c.GetAsync("http://localhost:5000/11"); //var p = NetRpcManager.CreateClientProxy<IService>(new Channel("localhost", 5000, ChannelCredentials.Insecure)); var p = NetRpcManager.CreateClientProxy <IService>(new GrpcClientOptions() { Host = "localhost", Port = 5001, PublicKey = PublicKey }); //await p.Proxy.Call("hello world."); var channel = new Channel("localhost", 5000, ChannelCredentials.Insecure); var client = new Greeter.GreeterClient(channel); var r = await client.SayHelloAsync(new HelloRequest() { Name = "n1" }); Console.Read(); }
static async Task Main(string[] args) { var proxy = NetRpcManager.CreateClientProxy <IServiceAsync>(Helper.GetMQOptions()).Proxy; for (var i = 0; i < 10; i++) { var i1 = i; Task.Run(async() => { Console.WriteLine($"Send {i1}"); await proxy.CallAsync(async p => Console.WriteLine(p), i1.ToString()); }); } //for (int i = 0; i < 10; i++) //{ // using (var stream = File.Open(Helper.GetTestFilePath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) // await proxy.PostAsync(i.ToString(), stream); // Console.WriteLine($"post {i}"); //} Console.WriteLine("Send end"); Console.Read(); }
static void Main(string[] args) { //RabbitMQ Console.WriteLine("--- [RabbitMQ] ---"); var mqF = new ClientConnectionFactory(Helper.GetMQParam()); var clientProxy = NetRpcManager.CreateClientProxy <IService>(mqF, false); clientProxy.Connected += (s, e) => Console.WriteLine("[event] Connected"); clientProxy.DisConnected += (s, e) => Console.WriteLine("[event] DisConnected"); clientProxy.ExceptionInvoked += (s, e) => Console.WriteLine("[event] ExceptionInvoked"); //Heartbeat clientProxy.Heartbeat += async s => { Console.WriteLine("[event] Heartbeat"); s.Proxy.Hearbeat(); }; clientProxy.StartHeartbeat(true); _proxy = clientProxy.Proxy; _proxyAsync = NetRpcManager.CreateClientProxy <IServiceAsync>(mqF, false).Proxy; RunTest(); RunTestAsync().Wait(); //Grpc Console.WriteLine("\r\n--- [Grpc] ---"); var grpcF = new NetRpc.Grpc.ClientConnectionFactory(new Channel("localhost", 50001, ChannelCredentials.Insecure)); _proxy = NetRpc.Grpc.NetRpcManager.CreateClientProxy <IService>(grpcF).Proxy; _proxyAsync = NetRpc.Grpc.NetRpcManager.CreateClientProxy <IServiceAsync>(grpcF).Proxy; RunTest(); RunTestAsync().Wait(); Console.WriteLine("Test end."); Console.Read(); }