Пример #1
0
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            Console.WriteLine("Calling GRPC Service");
            Console.Write("Hit enter to do the deed");
            Console.ReadLine();
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new Greeter.GreeterClient(channel);

            var reply = await client.SayHelloAsync(new HelloRequest { Name = "Putintane" });

            Console.WriteLine($"Got the response {reply.Message}");

            Console.WriteLine($"Got the response {reply.Message}");

            Console.WriteLine("Planning your route ...");

            var clientRouting = new DrivingRouter.DrivingRouterClient(channel);
            var request       = new RouteRequest {
                Street = "555 Mockingbird Ct.", City = "Des Moines", Zip = "23892"
            };
            var replyRoute = await clientRouting.PlanRouteAsync(request);

            Console.WriteLine("Arriving at " + replyRoute.ArrivalTime);
            Console.WriteLine("Miles: " + replyRoute.Miles);
            foreach (var step in replyRoute.Steps)
            {
                Console.WriteLine($"\t{step}");
            }
        }
Пример #2
0
        static async Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new DrivingRouter.DrivingRouterClient(channel);

            var request = new RouteRequest
            {
                StreetAddress = "555 Mockingbird Ct",
                City          = "Pasadena",
                Zip           = "44233"
            };

            var reply = await client.PlanRouteAsync(request);

            Console.WriteLine($"This is {reply.Miles} and should get you there at {reply.DrivingTime.ToDateTime()}");
            foreach (var step in reply.Steps)
            {
                Console.WriteLine($"\t{step}");
            }
        }
Пример #3
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Calling a GRPC Service");
            Console.Write("Hit enter to do the deed");
            Console.ReadLine();
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var client = new Greeter.GreeterClient(channel);

            var reply = await client.SayHelloAsync(new HelloRequest { Name = "Putintane" });

            Console.WriteLine($"Got the response {reply.Message}");

            Console.WriteLine("Planning your route...");


            var clientRouting = new DrivingRouter.DrivingRouterClient(channel);
            var request       = new RouteRequest {
                Street = "555 Mockingbird Ct.", City = "Des Moines", Zip = "23892"
            };
            var replyRoute = await clientRouting.PlanRouteAsync(request);

            Console.WriteLine("Arriving at " + replyRoute.ArrivalTime);
            Console.WriteLine("Miles: " + replyRoute.Miles);
            foreach (var step in replyRoute.Steps)
            {
                Console.WriteLine($"\t{step}");
            }

            Console.WriteLine("Hit Enter to Start Turn By Turn Directions");
            Console.ReadLine();
            var client3       = new TurnByTurn.TurnByTurnClient(channel);
            var streamingCall = client3.StartGuidance(new Empty());

            await foreach (var step in streamingCall.ResponseStream.ReadAllAsync())
            {
                Console.WriteLine($"Turn {step.Direction} at {step.Road}");
            }
        }