Skip to main content

# Unary

Behaves like a traditional request/response. The Client must initiate the connection Usually is one call -> one response

Unary RPCs where the client sends a single request to the server and gets a single response back, just like a normal function call.

### Details element example​

    rpc SayHello(HelloRequest) returns (HelloResponse);

     public override Task<Response> SayHello(Request request, ServerCallContext context)
            {
                #region context
                var contextv = context.GetHttpContext();

                var user = context.GetHttpContext().User;
                // ... access data from ClaimsPrincipal ...
                //  var clientCertificate = httpContext.Connection.ClientCertificate;
                #endregion

                return Task.FromResult(new Response
                {
                    Message = $"Hello back with : {request.Name} value from the {context.Host.ToString()} Server"

                });
            }

Consuming

    Request request = new Request() { ContentValue = "!" };

    Console.WriteLine($"sending: {request.ContentValue}");

    var response = client.SayHello(request, options: new CallOptions() { });