forked from jinq0123/grpc-lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBindServer.cpp
More file actions
38 lines (29 loc) · 1016 Bytes
/
BindServer.cpp
File metadata and controls
38 lines (29 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "BindServer.h"
#include "impl/Service.h" // for Service
#include <grpc_cb_core/server/server.h> // for Server
#include <LuaIntf/LuaIntf.h>
#include <string>
using namespace LuaIntf;
namespace {
void RegisterService(grpc_cb_core::Server* pServer, const LuaRef& luaService)
{
assert(pServer);
luaService.checkTable();
pServer->RegisterService(std::make_shared<impl::Service>(luaService));
} // RegisterService()
} // namespace
namespace server {
void BindServer(const LuaRef& mod)
{
using namespace grpc_cb_core;
LuaBinding(mod).beginClass<Server>("Server")
.addConstructor(LUA_ARGS())
// Returns bound port number on success, 0 on failure.
.addFunction("add_listening_port",
static_cast<int(Server::*)(const std::string&)>(
&Server::AddListeningPort))
.addFunction("register_service", &RegisterService)
.addFunction("run", &Server::Run)
.endClass(); // Server
} // BindServer()
} // namespace server