private static async Task StreamClientTest() { var channel = GrpcChannel.ForAddress("https://localhost:5001"); var client = new PaymentManager.PaymentManagerClient(channel); var statusResponse = client.GetPaymentStatus(new GetPaymentStatusRequest { OrderId = "abc" }); //CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); //CancellationToken token = cancellationTokenSource.Token; //cancellationTokenSource.Cancel(); var stream = statusResponse.ResponseStream.ReadAllAsync(); Random random = new Random(); await foreach (var status in stream) { await Task.Delay(TimeSpan.FromSeconds(random.NextDouble())); Console.WriteLine($"{status.Status}"); } }
private static async Task gRPCClientTest() { Console.WriteLine("Hello gRPC Client!"); var channel = GrpcChannel.ForAddress("https://localhost:5001"); var client = new PaymentManager.PaymentManagerClient(channel); var request = new MakePaymentRequest { ProductId = "Notebook", Quantity = 5, Address = "Plac Inwalidow" }; var response = await client.MakePaymentAsync(request); Console.WriteLine($"response: OrderId = {response.OrderId}"); }