Enabling bi-directional streaming
We have now reached the final type of gRPC call—a bi-directional streaming RPC. As the name suggests, this RPC can have both client-initiated and server-initiated streams – and those streams don't necessarily have to depend on one another.
Enabling server-side components for bi-directional streaming
As we did previously, first, we will add a bi-directional rpc
to the relevant proto
file. Then, we will add the method's implementation to our C# code:
- First, we will add the following
rpc
definition to theDeviceManager
service
definition in thedevice_management.proto
file, which is located in theGrpcDependencies
project:rpc UpdateAndConfirmBatch (stream DeviceDetails) returns (stream DeviceDetails);
- Add the following method signature to the
IDeviceStatusCache
interface of theDeviceManagerService
project:DeviceManagement.DeviceDetails GetDevice(int deviceId);
- Add the following method implementation to the...