Esempio n. 1
0
        public async Task <IActionResult> GetAsync()
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress("http://grpc");
            var client       = new Greeter.GreeterClient(channel);
            var personClient = new Person.PersonClient(channel);

            var personReply = await personClient.InsertPersonAsync(
                new PersonRequest { Name = "Marcel", Age = 44, CatName = "Jerry" });

            var reply = await client.SayHelloAsync(
                new HelloRequest { Name = "GreeterClient", Age = 42 });


            return(Ok(reply.Message + " " + personReply.Message));
        }
Esempio n. 2
0
        async static Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:32768/");
            var clientSimple = new Simple.SimpleClient(channel);
            var sampleResult = await clientSimple.GetSimpleDataAsync(new InRequest { Filter = "Prova" });



            var client = new Person.PersonClient(channel);
            PeopleFilterRequest filterRequest = new PeopleFilterRequest();
            var reply = await client.GetAllPeopleAsync(filterRequest);

            //var client = new Greeter.GreeterClient(channel);
            //var reply = await client.SayHelloAsync(
            //				  new HelloRequest { Name = "GreeterClient" });
            Console.ReadKey();
        }
Esempio n. 3
0
        static async Task Main(string[] args)
        {
            //creating the channel with GRPC server URL
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            //Creating the Client Instance of Greeter Server using the channel
            var client = new Greeter.GreeterClient(channel);
            //Consuming the Grpc Server Service using RPC call from Grpc Client
            HelloReply respone = await client.SayHelloAsync(new HelloRequest { Name = "SafeAuto" });

            Console.WriteLine($"{respone.Message}");

            var            client1  = new Person.PersonClient(channel);
            PersonResponse response = await client1.GetPersonByIdAsync(new PersonSearchRequest { Id = 1 });

            Console.WriteLine($"{response.Id}-{response.Firstname}-{response.Lastname}");
            Console.ReadLine();
        }