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

Function make_server_streaming_request

example/streaming-client.cpp:77–99  ·  view source on GitHub ↗

end-snippet

Source from the content-addressed store, hash-verified

75
76// end-snippet
77asio::awaitable<void> make_server_streaming_request(agrpc::GrpcContext& grpc_context, ExampleStub& stub)
78{
79 using RPC = agrpc::ClientRPC<&ExampleStub::PrepareAsyncServerStreaming>;
80
81 RPC rpc{grpc_context};
82 rpc.context().set_deadline(std::chrono::system_clock::now() + std::chrono::seconds(5));
83
84 example::v1::Request request;
85 request.set_integer(5);
86 abort_if_not(co_await rpc.start(stub, request));
87
88 example::v1::Response response;
89
90 while (co_await rpc.read(response))
91 {
92 std::cout << "ClientRPC: Server streaming: " << response.integer() << "\n";
93 }
94
95 const grpc::Status status = co_await rpc.finish();
96 abort_if_not(status.ok());
97
98 std::cout << "ClientRPC: Server streaming completed\n";
99}
100// ---------------------------------------------------
101//
102

Callers 1

mainFunction · 0.70

Calls 4

nowFunction · 0.85
startMethod · 0.45
readMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected