Socket library and Config library restructuring, improvement to UDP socket reliability
This commit is contained in:
parent
97752f2c2d
commit
3d26741148
37 changed files with 151 additions and 110 deletions
|
@ -265,7 +265,7 @@ int main_loop(int argc, char **argv){
|
|||
}
|
||||
if (Controller::Storage.isMember("config") && Controller::Storage["config"].isMember("debug") &&
|
||||
Controller::Storage["config"]["debug"].isInt()){
|
||||
Util::Config::printDebugLevel = Controller::Storage["config"]["debug"].asInt();
|
||||
Util::printDebugLevel = Controller::Storage["config"]["debug"].asInt();
|
||||
}
|
||||
// check for port, interface and username in arguments
|
||||
// if they are not there, take them from config file, if there
|
||||
|
|
|
@ -443,8 +443,8 @@ void Controller::handleUDPAPI(void *np){
|
|||
uSock.SetDestination(UDP_API_HOST, UDP_API_PORT);
|
||||
while (Controller::conf.is_active){
|
||||
if (uSock.Receive()){
|
||||
MEDIUM_MSG("UDP API: %s", uSock.data);
|
||||
JSON::Value Request = JSON::fromString(uSock.data, uSock.data_len);
|
||||
MEDIUM_MSG("UDP API: %s", (const char*)uSock.data);
|
||||
JSON::Value Request = JSON::fromString(uSock.data, uSock.data.size());
|
||||
Request["minimal"] = true;
|
||||
JSON::Value Response;
|
||||
if (Request.isObject()){
|
||||
|
@ -454,7 +454,7 @@ void Controller::handleUDPAPI(void *np){
|
|||
Response.removeMember("authorize");
|
||||
uSock.SendNow(Response.toString());
|
||||
}else{
|
||||
WARN_MSG("Invalid API command received over UDP: %s", uSock.data);
|
||||
WARN_MSG("Invalid API command received over UDP: %s", (const char*)uSock.data);
|
||||
}
|
||||
}else{
|
||||
Util::sleep(500);
|
||||
|
@ -515,9 +515,9 @@ void Controller::handleAPICommands(JSON::Value &Request, JSON::Value &Response){
|
|||
JSON::Value &out = Controller::Storage["config"];
|
||||
if (in.isMember("debug")){
|
||||
out["debug"] = in["debug"];
|
||||
if (Util::Config::printDebugLevel != (out["debug"].isInt() ? out["debug"].asInt() : DEBUG)){
|
||||
Util::Config::printDebugLevel = (out["debug"].isInt() ? out["debug"].asInt() : DEBUG);
|
||||
INFO_MSG("Debug level set to %u", Util::Config::printDebugLevel);
|
||||
if (Util::printDebugLevel != (out["debug"].isInt() ? out["debug"].asInt() : DEBUG)){
|
||||
Util::printDebugLevel = (out["debug"].isInt() ? out["debug"].asInt() : DEBUG);
|
||||
INFO_MSG("Debug level set to %u", Util::printDebugLevel);
|
||||
}
|
||||
}
|
||||
if (in.isMember("protocols")){
|
||||
|
|
|
@ -116,9 +116,9 @@ namespace Controller{
|
|||
argarr[argnum++] = (char *)(p[it.key()].c_str());
|
||||
}else{
|
||||
if (it.key() == "debug"){
|
||||
if (Util::Config::printDebugLevel != DEBUG){
|
||||
if (Util::printDebugLevel != DEBUG){
|
||||
static std::string debugLvlStr;
|
||||
debugLvlStr = JSON::Value(Util::Config::printDebugLevel).asString();
|
||||
debugLvlStr = JSON::Value(Util::printDebugLevel).asString();
|
||||
argarr[argnum++] = (char *)((*it)["option"].asStringRef().c_str());
|
||||
argarr[argnum++] = (char *)debugLvlStr.c_str();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue