Fix bug in deploy
[anna.git] / example / diameter / launcher / ProgrammedAnswers.cpp
index 5f6dd4f..8e310d7 100644 (file)
@@ -19,8 +19,7 @@
 
 void ProgrammedAnswers::clear () throw() {
   for (reacting_answers_const_iterator it = a_deques.begin(); it != a_deques.end(); it++) {
-       anna::diameter::codec::Engine *engine = anna::functions::component <Engine> (ANNA_FILE_LOCATION);
-       engine->releaseMessage(*(it->second->begin()));
+       a_codecEngine->releaseMessage(*(it->second->begin()));
        delete(it->second);
   }
   a_deques.clear();
@@ -46,6 +45,9 @@ void ProgrammedAnswers::dump () throw() {
 }
 
 void ProgrammedAnswers::addMessage(int code, anna::diameter::codec::Message *message) throw() {
+  if (!message) return; // just in case
+  message->setEngine(a_codecEngine); // just in case
+
   reacting_answers_const_iterator it = a_deques.find(code);
   if (it != a_deques.end()) {
        it->second->push_back(message);
@@ -70,12 +72,11 @@ void ProgrammedAnswers::nextMessage(int code) throw() { //pops the deque and rel
   reacting_answers_const_iterator it = a_deques.find(code);
   if (it != a_deques.end()) {
        if (!it->second->empty()) {
-         anna::diameter::codec::Engine *engine = anna::functions::component <Engine> (ANNA_FILE_LOCATION);
          if (a_rotate) {
                addMessage(code, *(it->second->begin()));
          }
          else {
-               engine->releaseMessage(*(it->second->begin()));
+               a_codecEngine->releaseMessage(*(it->second->begin()));
          }
          it->second->pop_front();
        }
@@ -89,6 +90,8 @@ std::string ProgrammedAnswers::asString(const char *queueName) const throw() {
   aux += "', Rotation ";
   aux += a_rotate ? "enabled":"disabled";
   result += anna::functions::highlightJustify(aux);
+  result += "Codec engine: ";
+  result += a_codecEngine->getClassName();
   if(a_deques.size() != 0) {
        for(reacting_answers_const_iterator it = a_deques.begin(); it != a_deques.end(); it++) {
          if (it->second->size() != 0) {