From 62d2896665d7685c7f2d9b29a9b3b6d4bc72719b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 10 Apr 2015 17:11:51 -0700 Subject: [PATCH] Add facility to register methods in C++ --- include/grpc++/channel_interface.h | 1 + src/cpp/client/channel.cc | 4 ++++ src/cpp/client/channel.h | 1 + 3 files changed, 6 insertions(+) diff --git a/include/grpc++/channel_interface.h b/include/grpc++/channel_interface.h index 7d50b452801a6..4d48974e69107 100644 --- a/include/grpc++/channel_interface.h +++ b/include/grpc++/channel_interface.h @@ -51,6 +51,7 @@ class ChannelInterface : public CallHook { public: virtual ~ChannelInterface() {} + virtual void *RegisterMethod(const char *method_name) = 0; virtual Call CreateCall(const RpcMethod& method, ClientContext* context, CompletionQueue* cq) = 0; }; diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc index 72123abbc8d60..5a39a3b801a2b 100644 --- a/src/cpp/client/channel.cc +++ b/src/cpp/client/channel.cc @@ -82,4 +82,8 @@ void Channel::PerformOpsOnCall(CallOpBuffer* buf, Call* call) { GRPC_TIMER_MARK(PERFORM_OPS_END, call->call()); } +void *Channel::RegisterMethod(const char *method) { + return grpc_channel_register_call(c_channel_, method, target_.c_str()); +} + } // namespace grpc diff --git a/src/cpp/client/channel.h b/src/cpp/client/channel.h index 3980eba237dfe..aaf4dbe10dcb1 100644 --- a/src/cpp/client/channel.h +++ b/src/cpp/client/channel.h @@ -54,6 +54,7 @@ class Channel GRPC_FINAL : public ChannelInterface { Channel(const grpc::string& target, grpc_channel* c_channel); ~Channel() GRPC_OVERRIDE; + virtual void *RegisterMethod(const char *method) GRPC_OVERRIDE; virtual Call CreateCall(const RpcMethod& method, ClientContext* context, CompletionQueue* cq) GRPC_OVERRIDE; virtual void PerformOpsOnCall(CallOpBuffer* ops, Call* call) GRPC_OVERRIDE;