Fix retransmission issues (order, tracing, etc.)
[anna.git] / example / diameter / launcher / MyDiameterEntity.cpp
index ae4a3db..d16974b 100644 (file)
 #include "Launcher.hpp"
 
 
+void MyDiameterEntity::eventRequestRetransmission(const anna::diameter::comm::ClientSession* clientSession, anna::diameter::comm::Message *request) throw() {
+
+  LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventRequestRetransmission", ANNA_FILE_LOCATION));
+
+  // Base class:
+  Entity::eventRequestRetransmission(clientSession, request); // warning trace
+
+  // Performance stats:
+  Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
+  CommandLine& cl(anna::CommandLine::instantiate());
+  // CommandId:
+  anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(request->getBody());
+  LOGDEBUG
+  (
+    std::string msg = "Request retransmitted: ";
+    msg += anna::diameter::functions::commandIdAsPairString(cid);
+    msg += " | DiameterServer: ";
+    msg += anna::functions::socketLiteralAsString(clientSession->getAddress(), clientSession->getPort());
+    msg += " | EventTime: ";
+    msg += anna::time::functions::currentTimeAsString();
+    anna::Logger::debug(msg, ANNA_FILE_LOCATION);
+  );
+
+  // Write retransmission
+  if(my_app.logEnabled()) my_app.writeLogFile(request->getBody(), "retry", clientSession->asString(), a_codecEngine);
+}
+
+
 void MyDiameterEntity::eventRequest(anna::diameter::comm::ClientSession *clientSession, const anna::DataBlock &message)
 throw(anna::RuntimeException) {
   LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventRequest", ANNA_FILE_LOCATION));