static void Main(string[] args) { Channel channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure); var client = new Calculate.CalculateClient(channel); string opr = "*"; int i = 0; while (i < 100) { i++; var number1 = new Random().Next(100); var number2 = new Random().Next(100); var reply = client.GetResult(new ActionRequest() { Number1 = number1, Number2 = number2, Operation = opr }); Console.WriteLine(number1 + " " + opr + " " + number2 + " --->>> " + reply.Result); Thread.Sleep(1000); } channel.ShutdownAsync().Wait(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
private static async Task <double> GrpcSquareRequestAsync() { using var channel = GrpcChannel.ForAddress("https://localhost:5001"); var client = new Calculate.CalculateClient(channel); var result = await client.ExecAsync(new ExponentiationRequest(ExponentiationRequest.Types.Op.Square, 3)); return(result.Result); }
static async Task Main(string[] args) { //***************************************** // var channel = GrpcChannel.ForAddress("http://localhost:5000"); // var client = new Greeter.GreeterClient(channel); // HelloReply response = await client.SayHelloAsync(new HelloRequest { Name = "Düzgün Tutar" }); // Console.WriteLine(response.Message); //******************************************* var channel = GrpcChannel.ForAddress("http://localhost:5000"); var client = new Calculate.CalculateClient(channel); SumResponse response = await client.SumAsync(new SumRequest { S1 = 12, S2 = 15 }); Console.WriteLine(response.Result); }