aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/ext/channel.cc
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-07-24 10:43:27 -0700
committerGravatar murgatroid99 <mlumish@google.com>2015-07-24 10:43:27 -0700
commitea12b97243f95d1830a9f70c3c176b82ef37cb04 (patch)
tree53e4b2cfc5efed35772ae31f288f939aea90449a /src/node/ext/channel.cc
parent2e7ce156354f77bcbdfe0c096b6fa29ebe320200 (diff)
Exposed channel target and call peer in Node wrapper
Diffstat (limited to 'src/node/ext/channel.cc')
-rw-r--r--src/node/ext/channel.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/node/ext/channel.cc b/src/node/ext/channel.cc
index d37bf763dd..0b7333e450 100644
--- a/src/node/ext/channel.cc
+++ b/src/node/ext/channel.cc
@@ -76,6 +76,8 @@ void Channel::Init(Handle<Object> exports) {
tpl->InstanceTemplate()->SetInternalFieldCount(1);
NanSetPrototypeTemplate(tpl, "close",
NanNew<FunctionTemplate>(Close)->GetFunction());
+ NanSetPrototypeTemplate(tpl, "getTarget",
+ NanNew<FunctionTemplate>(GetTarget)->GetFunction());
NanAssignPersistent(fun_tpl, tpl);
Handle<Function> ctr = tpl->GetFunction();
constructor = new NanCallback(ctr);
@@ -185,5 +187,14 @@ NAN_METHOD(Channel::Close) {
NanReturnUndefined();
}
+NAN_METHOD(Channel::GetTarget) {
+ NanScope();
+ if (!HasInstance(args.This())) {
+ return NanThrowTypeError("getTarget can only be called on Channel objects");
+ }
+ Channel *channel = ObjectWrap::Unwrap<Channel>(args.This());
+ NanReturnValue(NanNew(grpc_channel_get_target(channel->wrapped_channel)));
+}
+
} // namespace node
} // namespace grpc