X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2FMyHandler.cpp;fp=example%2Fdiameter%2Flauncher%2FMyHandler.cpp;h=49205eda15126009a4e5535550de28aa451a9bee;hb=c56124ff93e8bceec159748dfe5ba8d56c62e3de;hp=ed49f4f125c8ba1f86b2e164a2c05e00e59e133a;hpb=220eecc7d53ddb85f72d94d5053738519fd8d27e;p=anna.git diff --git a/example/diameter/launcher/MyHandler.cpp b/example/diameter/launcher/MyHandler.cpp index ed49f4f..49205ed 100644 --- a/example/diameter/launcher/MyHandler.cpp +++ b/example/diameter/launcher/MyHandler.cpp @@ -114,7 +114,7 @@ throw(anna::RuntimeException) { } catch(anna::RuntimeException &ex) { ex.trace(); - LOGINFORMATION(anna::Logger::information("XXXXXXXXXXXX EXCEPCION PENDIENTE DE CATCHEAR ABAJO !!! XXXXXXXXXXXXXXXXX", ANNA_FILE_LOCATION)); + LOGINFORMATION(anna::Logger::information("doPOST exception: TODO control in inner method. Check traces", ANNA_FILE_LOCATION)); } } @@ -252,15 +252,26 @@ bool MyHandler::doPOST(const std::string &uri, const nlohmann::json &j, std::str // Flow operations else if ((opType == "/sendmsg2e")||(opType == "/sendmsg2c")) { - auto it = j.find("diameterJson"); - if (it != j.end()) + auto itJ = j.find("diameterJson"); + if (itJ != j.end()) { if (opType == "/sendmsg2e") - result = eop.sendmsg2e(response, it->dump(4)); // get the object as string (always indentation = 4) + result = eop.sendmsg_hex_2e(response, itJ->dump(4), true); // get the object as string (always indentation = 4) else - result = eop.sendmsg2c(response, it->dump(4)); // get the object as string (always indentation = 4) + result = eop.sendmsg_hex_2c(response, itJ->dump(4), true); // get the object as string (always indentation = 4) + } else response += "missing 'diameterJson' object field"; } + else if ((opType == "/sendhex2e")||(opType == "/sendhex2c")) { + auto itH = j.find("diameterHex"); + if (itH != j.end()) + if (opType == "/sendhex2e") + result = eop.sendmsg_hex_2e(response, *itH, false); + else + result = eop.sendmsg_hex_2c(response, *itH, false); + else + response += "missing 'diameterHex' string field"; + } else if ((opType == "/answermsg2e")||(opType == "/answermsg2c")) { auto itJ = j.find("diameterJson"); auto itA = j.find("action"); @@ -268,33 +279,20 @@ bool MyHandler::doPOST(const std::string &uri, const nlohmann::json &j, std::str bool hasA = (itA != j.end()); if (hasJ != hasA) { // XOR - - if (opType == "/answermsg2e") { - if (hasJ) - result = eop.answermsg2e(response, itJ->dump(4)); // get the object as string (always indentation = 4) - else - result = eop.answermsg2e_action(response, *itA); - } - else { - if (hasJ) - result = eop.answermsg2c(response, itJ->dump(4)); // get the object as string (always indentation = 4) - else - result = eop.answermsg2c_action(response, *itA); + std::string action; + if (hasA) { + action = *itA; + if (action == "") action = "list"; // default if missing } + + if (opType == "/answermsg2e") + result = eop.answermsg_action_2e(response, (hasJ ? itJ->dump(4) : action), hasJ); // itJ: get the object as string (always indentation = 4) + else + result = eop.answermsg_action_2c(response, (hasJ ? itJ->dump(4) : action), hasJ); // itJ: get the object as string (always indentation = 4) } else response += "missing 'diameterJson' object or 'action' string field (only one accepted)"; } - else if ((opType == "/sendhex2e")||(opType == "/sendhex2c")) { - auto it = j.find("diameterHex"); - if (it != j.end()) - if (opType == "/sendhex2e") - result = eop.sendhex2e(response, *it); - else - result = eop.sendhex2c(response, *it); - else - response += "missing 'diameterHex' string field"; - } // FSM testing // test_id__