예제 #1
0
파일: Program.cs 프로젝트: Nomak5/grpc_tuto
        public static async Task Main(string[] args)
        {
            Channel channel = new Channel("localhost:50051", ChannelCredentials.Insecure);

            var    client    = new Greeter.GreeterClient(channel);
            string firstName = "David";
            string lastName  = "Huet";

            var reply = client.Hello(new HelloRequest {
                Name = firstName, Lastname = lastName
            });

            Console.WriteLine("HelloRequest: " + reply.Message);
            var reply2 = client.GoodBye(new HelloRequest {
                Name = firstName, Lastname = lastName
            });

            Console.WriteLine("GoodByeRequest: " + reply2.Message);

            var call = client.AsyncHello(new HelloRequest {
                Name = firstName, Lastname = lastName
            });

            while (await call.ResponseStream.MoveNext())
            {
                Console.WriteLine("AsyncHello: " + call.ResponseStream.Current.Message);
            }

            channel.ShutdownAsync().Wait();

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }