pull/2702/head
yang-g 10 years ago
parent 26d533ebb8
commit c07d9bf668
  1. 2
      include/grpc++/client_context.h
  2. 11
      src/cpp/client/client_context.cc

@ -118,6 +118,8 @@ class ClientContext {
std::shared_ptr<const AuthContext> auth_context() const;
grpc::string peer() const;
// Get and set census context
void set_census_context(census_context* ccp) { census_context_ = ccp; }
census_context* get_census_context() const { return census_context_; }

@ -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

Loading…
Cancel
Save