提交 d889dd22 authored 作者: blu's avatar blu

big refacting of communitation architect

上级 c4ea9a30
...@@ -21,11 +21,14 @@ using namespace httplib; ...@@ -21,11 +21,14 @@ using namespace httplib;
using namespace nlohmann; using namespace nlohmann;
// //
class HttpSrv {
#define KEY_CONFIG_MAP "configmap" #define KEY_CONFIG_MAP "configmap"
class EvCloudSvc {
private: private:
Server svr; Server svr;
void *pRouterCtx = NULL, *pRouter = NULL;
string httpPort = "8089";
string msgPort = "5048";
// sn:module -> sn_of_evmgr // sn:module -> sn_of_evmgr
json configMap; json configMap;
...@@ -399,18 +402,35 @@ public: ...@@ -399,18 +402,35 @@ public:
res.set_content(j.dump(), "text/json"); res.set_content(j.dump(), "text/json");
}); });
svr.listen("0.0.0.0", 8089); svr.listen("0.0.0.0", stoi(httpPort));
} }
HttpSrv() EvCloudSvc()
{ {
int ret = 0;
char *strEnv = getenv("HTTP_PORT");
if(strEnv != NULL) {
httpPort = strEnv;
}
strEnv = getenv("MSG_PORT");
if(strEnv != NULL) {
msgPort = strEnv;
}
string addr = "tcp://*:" + msgPort;
ret = zmqhelper::setupRouter(&pRouterCtx, &pRouter, addr);
if(ret < 0) {
spdlog::error("evcloudsvc failed setup router: {}", addr);
exit(1);
}
}; };
~HttpSrv() {}; ~EvCloudSvc() {};
}; };
int main() int main()
{ {
HttpSrv srv; EvCloudSvc srv;
srv.run(); srv.run();
} }
\ No newline at end of file
...@@ -115,8 +115,8 @@ class EvDaemon{ ...@@ -115,8 +115,8 @@ class EvDaemon{
spdlog::info("evdaemon {} created subsystem {}", devSn, peerId); spdlog::info("evdaemon {} created subsystem {}", devSn, peerId);
} }
}else{ }else{
// TODO: // TODO
} }
} }
// startup other submodules // startup other submodules
......
...@@ -77,7 +77,7 @@ private: ...@@ -77,7 +77,7 @@ private:
addr = "tcp://*:" + to_string(config["port-router"]); addr = "tcp://*:" + to_string(config["port-router"]);
// setup zmq // setup zmq
// TODO: connect to cloud // TODO: connect to cloud
// router service // router service
pRouterCtx = zmq_ctx_new(); pRouterCtx = zmq_ctx_new();
pRouter = zmq_socket(pRouterCtx, ZMQ_ROUTER); pRouter = zmq_socket(pRouterCtx, ZMQ_ROUTER);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论