Esempio n. 1
0
        public IActionResult Count(ContadorRequest request)
        {
            var obj = new RESTCommon.ContadorReply
            {
                Message = $"Name: {request.Name}, Count: {_count++}"
            };

            return(Ok(obj));
        }
Esempio n. 2
0
        public async Task <IActionResult> Count_gRPC()
        {
            // The port number(5001) must match the port of the gRPC server.
            var channel         = GrpcChannel.ForAddress("https://localhost:5001");
            var client          = new Contador.ContadorClient(channel);
            var contadorRequest = new ContadorRequest {
                Name = "Test"
            };

            Stopwatch timer = new Stopwatch();

            timer.Start();
            var reply = await client.CountAsync(contadorRequest);

            timer.Stop();
            reply.RequestTime = timer.ElapsedMilliseconds.ToString();
            return(Ok(reply));
        }
Esempio n. 3
0
        public async Task <IActionResult> Count_REST()
        {
            var contadorRequest = new ContadorRequest {
                Name = "Test"
            };
            var json = JsonConvert.SerializeObject(contadorRequest);
            var data = new StringContent(json, Encoding.UTF8, "application/json");

            var client = new HttpClient();

            Stopwatch timer = new Stopwatch();

            timer.Start();
            var response = await client.PostAsync("https://localhost:44339/Count/Count", data);

            var content = await response.Content.ReadAsStringAsync();

            var reply = JsonConvert.DeserializeObject <RESTCommon.ContadorReply>(content);

            timer.Stop();

            reply.RequestTime = timer.ElapsedMilliseconds.ToString();
            return(Ok(reply));
        }