Gives application control over event DPA received for both client and entity
[anna.git] / example / diameter / launcher / main.cpp
index 35b283c..4b36441 100644 (file)
@@ -300,6 +300,7 @@ class MyDiameterEntity : public anna::diameter::comm::Entity {
   void eventResponse(const anna::diameter::comm::Response&) throw(anna::RuntimeException);
   void eventRequest(anna::diameter::comm::ClientSession *, const anna::DataBlock&) throw(anna::RuntimeException);
   void eventUnknownResponse(anna::diameter::comm::ClientSession *, const anna::DataBlock&) throw(anna::RuntimeException);
+  void eventDPA(anna::diameter::comm::ClientSession *, const anna::DataBlock&) throw(anna::RuntimeException);
 
   // Reimplementation
   int readSocketId(const anna::diameter::comm::Message* message, int maxClientSessions) const throw();
@@ -310,6 +311,7 @@ class MyLocalServer : public anna::diameter::comm::LocalServer {
   void eventResponse(const anna::diameter::comm::Response&) throw(anna::RuntimeException);
   void eventRequest(anna::diameter::comm::ServerSession *, const anna::DataBlock&) throw(anna::RuntimeException);
   void eventUnknownResponse(anna::diameter::comm::ServerSession *, const anna::DataBlock&) throw(anna::RuntimeException);
+  void eventDPA(anna::diameter::comm::ServerSession *, const anna::DataBlock&) throw(anna::RuntimeException);
 };
 
 class MyDiameterEngine : public anna::diameter::comm::Engine {
@@ -2417,8 +2419,27 @@ throw(anna::RuntimeException) {
   if(my_app.logEnabled()) my_app.writeLogFile(message, "recvfe-ans-unknown", clientSession->asString());
 }
 
+void MyDiameterEntity::eventDPA(anna::diameter::comm::ClientSession *clientSession, const anna::DataBlock &message)
+throw(anna::RuntimeException) {
+  LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventDPA", ANNA_FILE_LOCATION));
+  // Performance stats:
+  Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
+  // CommandId:
+  anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message);
+  LOGDEBUG
+  (
+    std::string msg = "Disconnect-Peer-Answer received from entity: ";
+    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 reception
+  if(my_app.logEnabled()) my_app.writeLogFile(message, "recvfe", clientSession->asString());
+}
 
 void MyLocalServer::eventRequest(anna::diameter::comm::ServerSession *serverSession, const anna::DataBlock &message)
 throw(anna::RuntimeException) {
@@ -2618,6 +2639,26 @@ throw(anna::RuntimeException) {
   if(my_app.logEnabled()) my_app.writeLogFile(message, "recvfc-ans-unknown", serverSession->asString());
 }
 
+void MyLocalServer::eventDPA(anna::diameter::comm::ServerSession *serverSession, const anna::DataBlock &message)
+throw(anna::RuntimeException) {
+  LOGMETHOD(anna::TraceMethod tm("launcher::MyLocalServer", "eventDPA", ANNA_FILE_LOCATION));
+  // Performance stats:
+  Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
+  // CommandId:
+  anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message);
+  LOGDEBUG
+  (
+    std::string msg = "Disconnect-Peer-Answer response received from client: ";
+    msg += anna::diameter::functions::commandIdAsPairString(cid);
+    msg += " | DiameterServer: ";
+    msg += anna::functions::socketLiteralAsString(serverSession->getAddress(), serverSession->getPort());
+    msg += " | EventTime: ";
+    msg += anna::time::functions::currentTimeAsString();
+    anna::Logger::debug(msg, ANNA_FILE_LOCATION);
+  );
+
+  if(my_app.logEnabled()) my_app.writeLogFile(message, "recvfc", serverSession->asString());
+}
 
 anna::xml::Node* Launcher::asXML(anna::xml::Node* parent) const
 throw() {