aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/cpp/helloworld/greeter_async_client.cc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cpp/helloworld/greeter_async_client.cc')
-rw-r--r--examples/cpp/helloworld/greeter_async_client.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/cpp/helloworld/greeter_async_client.cc b/examples/cpp/helloworld/greeter_async_client.cc
index 64da044ea6..ddf6c1aaf3 100644
--- a/examples/cpp/helloworld/greeter_async_client.cc
+++ b/examples/cpp/helloworld/greeter_async_client.cc
@@ -60,11 +60,15 @@ class GreeterClient {
// Storage for the status of the RPC upon completion.
Status status;
- // stub_->AsyncSayHello() performs the RPC call, returning an instance we
- // store in "rpc". Because we are using the asynchronous API, we need to
- // hold on to the "rpc" instance in order to get updates on the ongoing RPC.
+ // stub_->PrepareAsyncSayHello() creates an RPC object, returning
+ // an instance to store in "call" but does not actually start the RPC
+ // Because we are using the asynchronous API, we need to hold on to
+ // the "call" instance in order to get updates on the ongoing RPC.
std::unique_ptr<ClientAsyncResponseReader<HelloReply> > rpc(
- stub_->AsyncSayHello(&context, request, &cq));
+ stub_->PrepareAsyncSayHello(&context, request, &cq));
+
+ // StartCall initiates the RPC call
+ rpc->StartCall();
// Request that, upon completion of the RPC, "reply" be updated with the
// server's response; "status" with the indication of whether the operation