3 * Copyright 2015 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #ifndef NET_GRPC_NODE_CHANNEL_H_
20 #define NET_GRPC_NODE_CHANNEL_H_
24 #include "grpc/grpc.h"
29 bool ParseChannelArgs(v8::Local<v8::Value> args_val,
30 grpc_channel_args **channel_args_ptr);
32 void DeallocateChannelArgs(grpc_channel_args *channel_args);
34 /* Wrapper class for grpc_channel structs */
35 class Channel : public Nan::ObjectWrap {
37 static void Init(v8::Local<v8::Object> exports);
38 static bool HasInstance(v8::Local<v8::Value> val);
39 /* This is used to typecheck javascript objects before converting them to
41 static v8::Persistent<v8::Value> prototype;
43 /* Returns the grpc_channel struct that this object wraps */
44 grpc_channel *GetWrappedChannel();
47 explicit Channel(grpc_channel *channel);
51 Channel(const Channel &);
52 Channel &operator=(const Channel &);
54 static NAN_METHOD(New);
55 static NAN_METHOD(Close);
56 static NAN_METHOD(GetTarget);
57 static NAN_METHOD(GetConnectivityState);
58 static NAN_METHOD(WatchConnectivityState);
59 static NAN_METHOD(CreateCall);
60 static Nan::Callback *constructor;
61 static Nan::Persistent<v8::FunctionTemplate> fun_tpl;
63 grpc_channel *wrapped_channel;
69 #endif // NET_GRPC_NODE_CHANNEL_H_