Unary gRPC Calls
Learn about the unary call types in gRPC and how to implement them.
We'll cover the following...
There are four call types supported by gRPC: unary, server-streaming, client-streaming, and bi-directional streaming calls. The most simple gRPC call is a unary call. This type of call accepts a single request message and returns a single response message. It can be used in any scenario where either a single object needs to be retrieved from the server or a single action needs to be triggered.
Previously, we had a look at unary gRPC calls in all our examples so far. Now, we'll have a more detailed look at it and its C# implementation. The code widget below has the initial gRPC client and server projects.
syntax = "proto3";
option csharp_namespace = "BasicGrpcService";
package basic_grpc_service;
service Chatbot {
rpc SendMessage (ChatRequest) returns (ChatReply);
}
message ChatRequest {
string name = 1;
string message = 2;
}
message ChatReply {
string message = 1;
}
In this solution, BasicGrpcService is a gRPC server project, while BasicGrpcClient is a console application that contains some basic gRPC client capabilities. To have a look at how unary calls are set up in Protobuf, we can open either of the chatbot.proto ...