end-snippet
| 75 | |
| 76 | // end-snippet |
| 77 | asio::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 |