aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/server.h
diff options
context:
space:
mode:
authorGravatar murgatroid99 <michael.lumish@gmail.com>2015-01-12 18:14:35 -0800
committerGravatar murgatroid99 <michael.lumish@gmail.com>2015-01-12 18:14:35 -0800
commite5061519185627e58495bede780f757339ba07c5 (patch)
tree7bf63f4bcc35d2141351d8cf29fac7a6eb5dfe63 /src/node/server.h
parent470a3ea1a192e53a61012c30a6a9a5efcc712948 (diff)
Clean commit of Node.js library source
Diffstat (limited to 'src/node/server.h')
-rw-r--r--src/node/server.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/node/server.h b/src/node/server.h
new file mode 100644
index 0000000000..5edf9557f5
--- /dev/null
+++ b/src/node/server.h
@@ -0,0 +1,46 @@
+#ifndef NET_GRPC_NODE_SERVER_H_
+#define NET_GRPC_NODE_SERVER_H_
+
+#include <node.h>
+#include <nan.h>
+#include "grpc/grpc.h"
+
+namespace grpc {
+namespace node {
+
+/* Wraps grpc_server as a JavaScript object. Provides a constructor
+ and wrapper methods for grpc_server_create, grpc_server_request_call,
+ grpc_server_add_http2_port, and grpc_server_start. */
+class Server : public ::node::ObjectWrap {
+ public:
+ /* Initializes the Server class and exposes the constructor and
+ wrapper methods to JavaScript */
+ static void Init(v8::Handle<v8::Object> exports);
+ /* Tests whether the given value was constructed by this class's
+ JavaScript constructor */
+ static bool HasInstance(v8::Handle<v8::Value> val);
+
+ private:
+ explicit Server(grpc_server *server);
+ ~Server();
+
+ // Prevent copying
+ Server(const Server&);
+ Server& operator=(const Server&);
+
+ static NAN_METHOD(New);
+ static NAN_METHOD(RequestCall);
+ static NAN_METHOD(AddHttp2Port);
+ static NAN_METHOD(AddSecureHttp2Port);
+ static NAN_METHOD(Start);
+ static NAN_METHOD(Shutdown);
+ static v8::Persistent<v8::Function> constructor;
+ static v8::Persistent<v8::FunctionTemplate> fun_tpl;
+
+ grpc_server *wrapped_server;
+};
+
+} // namespace node
+} // namespace grpc
+
+#endif // NET_GRPC_NODE_SERVER_H_