MCPcopy Create free account
hub / github.com/Tradias/asio-grpc / handle_server_streaming_request

Function handle_server_streaming_request

example/unifex-server.cpp:75–93  ·  view source on GitHub ↗

end-snippet

Source from the content-addressed store, hash-verified

73
74// end-snippet
75auto handle_server_streaming_request(agrpc::GrpcContext& grpc_context, example::v1::Example::AsyncService& service)
76{
77 return agrpc::register_sender_rpc_handler<ServerStreamingRPC>(
78 grpc_context, service,
79 [&](ServerStreamingRPC& rpc, const ServerStreamingRPC::Request& request) -> unifex::task<void>
80 {
81 for (google::protobuf::int32 i = 0; i < request.integer(); ++i)
82 {
83 example::v1::Response response;
84 response.set_integer(i);
85 if (!co_await rpc.write(response))
86 {
87 // The client hung up.
88 co_return;
89 }
90 }
91 co_await rpc.finish(grpc::Status::OK);
92 });
93}
94// ---------------------------------------------------
95//
96

Callers 1

mainFunction · 0.70

Calls 2

writeMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected