AspNetCore.Docs/aspnetcore/grpc/configuration/sample/Program2.cs

26 lines
708 B
C#

using System;
using System.Threading.Tasks;
using Greet;
using Grpc.Core;
using Grpc.Core.Interceptors;
using Grpc.Net.Client;
namespace GrpcGreeterClient
{
class Program
{
#region snippet
static async Task Main(string[] args)
{
var channel = GrpcChannel.ForAddress("https://localhost:5001");
var callInvoker = channel.Intercept(new LoggingInterceptor());
var client = new Greeter.GreeterClient(callInvoker);
var reply = await client.SayHelloAsync(
new HelloRequest { Name = "GreeterClient" });
Console.WriteLine("Greeting: " + reply.Message);
}
#endregion
}
}