diff options
Diffstat (limited to 'src/cpp/client')
-rw-r--r-- | src/cpp/client/client_context.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 14ab772e50..c38d0c1df6 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -34,6 +34,7 @@ #include <grpc++/client_context.h> #include <grpc/grpc.h> +#include <grpc/support/alloc.h> #include <grpc/support/string_util.h> #include <grpc++/credentials.h> #include <grpc++/time.h> @@ -104,4 +105,14 @@ void ClientContext::TryCancel() { } } +grpc::string ClientContext::peer() const { + grpc::string peer; + if (call_) { + char* c_peer = grpc_call_get_peer(call_); + peer = c_peer; + gpr_free(c_peer); + } + return peer; +} + } // namespace grpc |