提交 8b84f720 authored 作者: bruce.lu's avatar bruce.lu

init

上级 4d8be15f
......@@ -39,6 +39,8 @@ evmlmotion: evmlmotion.cpp inc/common.hpp inc/avcvhelpers.hpp inc/database.h inc
evdaemon: evdaemon.cpp inc/common.hpp inc/database.h inc/zmqhelper.hpp inc/tinythread.hpp database.cpp
$(CPP) $(CPPFLAGS) $(LD_FLAGS) -o evdaemon evdaemon.cpp database.cpp $(SQLITE) $(HEADERS) `pkg-config --cflags --libs vendor/lib/pkgconfig/libzmq.pc` $(LIBS)
evcloudsvc: evcloudsvc.cpp inc/utils.hpp inc/database.h inc/zmqhelper.hpp inc/tinythread.hpp database.cpp
$(CPP) $(CPPFLAGS) $(LD_FLAGS) -o evcloudsvc evcloudsvc.cpp inc/utils.hpp database.cpp $(SQLITE) $(HEADERS) `pkg-config --cflags --libs vendor/lib/pkgconfig/libzmq.pc` $(LIBS)
rtspr: rtsp-relay.cpp
$(CPP) $(CPPFLAGS) $(LD_FLAGS) -o rtspr rtsp-relay.cpp $(LIBFFMPEG) $(LD_FLAGS)
......
......@@ -12,6 +12,7 @@ update: 2019/09/02
#include "inc/json.hpp"
#include "inc/spdlog/spdlog.h"
#include "utils.hpp"
#include "inc/zmqhelper.hpp"
using namespace std;
using namespace httplib;
......@@ -31,7 +32,7 @@ class HttpSrv{
// load configmap
json cnfm;
LVDB::getValue(cnfm, "configmap");
if(cnfm.size != 0){
if(cnfm.size() != 0){
this->configMap = cnfm;
}
......@@ -40,14 +41,21 @@ class HttpSrv{
ret["code"] = 0;
ret["time"] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
ret["msg"] = "ok";
if(!req.has_param("sn") || !req.has_param("module")){
if(!req.has_param("sn") || !req.has_param("module")||req.get_param_value("module").size()< 4){
ret["code"] = 1;
ret["msg"] = "evcloud bad req: no sn/module param";
spdlog::error("evcloud bad req: {}", req);
spdlog::error(ret["msg"].get<string>());
}else{
string sn = req.get_param_value("sn");
string module = req.get_param_value("module");
string key = sn + ":" + module;
string modname = module.substr(0,4);
if(modname == "evml") {
modname = "evml:" + module.substr(4, module.size());
}else{
modname = module;
}
string key = sn + ":" + modname;
if(this->configMap.count(key) != 0) {
json config;
ret = LVDB::getLocalConfig(config, this->configMap[key]);
......@@ -55,7 +63,7 @@ class HttpSrv{
if(ret < 0) {
ret["code"] = 1;
ret["msg"] = "evcloud failed to get config with k, v:" + key + " " + this->configMap[key].get<string>();
spdlog::error(ret["msg"]);
spdlog::error(ret["msg"].get<string>());
}else{
ret["data"] = config;
}
......@@ -78,7 +86,7 @@ class HttpSrv{
if(newConfig.count("data") == 0 || newConfig["data"].size() == 0) {
ret["code"] = 1;
ret["msg"] = "evcloudsvc invalid config body received: " + req.body;
spdlog::error(ret["msg"]);
spdlog::error(ret["msg"].get<string>());
}else{
json &data = newConfig["data"];
for(auto &[k, v]: data.items()) {
......@@ -86,7 +94,7 @@ class HttpSrv{
if(v.count(k) == 0||v[k].size()==0) {
ret["code"] = 2;
ret["msg"] = "evcloudsvc invalid value for key " + k;
spdlog::error(ret["msg"]);
spdlog::error(ret["msg"].get<string>());
continue;
}else{
// find all modules
......@@ -106,9 +114,9 @@ class HttpSrv{
string modKey;
//ml
if(mn == "evml" && ml.count("type") != 0 && ml["type"].size() != 0) {
modKey = ml["sn"] + ":evml:" + ml["type"];
modKey = ml["sn"].get<string>() +":evml:" + ml["type"].get<string>();
}else{
modKey = ml["sn"] + ":" + mn;
modKey = ml["sn"].get<string>() + ":" + mn;
}
this->configMap[modKey] = v;
}
......@@ -117,7 +125,7 @@ class HttpSrv{
} // for ipc
}
}
// update
// update evmgr config
auto lastupdated = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
json evmgrData;
v["lastupdated"] = lastupdated;
......
......@@ -101,7 +101,8 @@ vector<vector<uint8_t> > z_recv_multiple(void *s, bool nowait=false)
// proto [sender_id(only when no identifier set in setsockopts)] [target_id] [body]
int z_send_multiple(void *s, vector<vector<uint8_t> >&body)
{
int cnt = 0, ret = 0;
size_t cnt = 0;
int ret = 0;
zmq_msg_t msg;
for(auto &i:body) {
ret = zmq_msg_init_size(&msg, i.size());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论