static async Task Main(string[] args) { //var helloRequest = new HelloRequest { Name = "Jon" }; //var channel = GrpcChannel.ForAddress("https://localhost:5001"); //var client = new Greeter.GreeterClient(channel); //var reply = await client.SayHelloAsync(helloRequest); var channel = GrpcChannel.ForAddress("https://localhost:5001"); var customerClient = new Customers.CustomersClient(channel); var clientRequested = new CustomerLookupModel() { UserId = 2 }; var customer = await customerClient.GetCustomerInfoAsync(clientRequested); Console.WriteLine($"{customer.FirstName} {customer.LastName}"); Console.WriteLine("New customer list:"); using (var call = customerClient.GetNewCustomers(new NewCustomeRequest())) { while (await call.ResponseStream.MoveNext()) { var currentCustomer = call.ResponseStream.Current; Console.WriteLine($"{currentCustomer.FirstName} {currentCustomer.LastName} {currentCustomer.EmailAddress}"); } } Console.WriteLine("Second new customer list:"); using (var call = customerClient.GetNewCustomers(new NewCustomeRequest())) { await foreach (var currentCustomer in call.ResponseStream.ReadAllAsync()) { Console.WriteLine($"{currentCustomer.FirstName} {currentCustomer.LastName}: {currentCustomer.EmailAddress}"); } } Console.ReadLine(); }
static async Task Main(string[] args) { int x = 0; Console.WriteLine("Hello World!"); var channel = GrpcChannel.ForAddress("https://localhost:5001"); var greeterClient = new Greeter.GreeterClient(channel); var customerClient = new Customers.CustomersClient(channel); var reply = await greeterClient.SayHelloAsync(new HelloRequest { Name = "Jon-Ajumobi Olamide D." }); Console.WriteLine($"Message is: {reply.Message}"); using (var customer = customerClient.GetCustomers(new EmptyModel())) { while (await customer.ResponseStream.MoveNext()) { var current = customer.ResponseStream.Current; Console.WriteLine($"{++x}. Customer Name: {current.Name}, Customer Email: {current.Email}"); } } Console.ReadLine(); }