Node class, command line redesign. New xml template for process configuration.
[anna.git] / example / diameter / launcher / MyDiameterEntity.hpp
index e69de29..a9ad2c4 100644 (file)
@@ -0,0 +1,60 @@
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+#ifndef example_diameter_launcher_MyDiameterEntity_hpp
+#define example_diameter_launcher_MyDiameterEntity_hpp
+
+// Project
+#include <anna/diameter.comm/Entity.hpp>
+
+// Process
+#include "ProgrammedAnswers.hpp"
+
+namespace anna {
+  namespace diameter {
+    namespace codec {
+      class Engine;
+    }
+  }
+}
+
+class MyDiameterEntity : public anna::diameter::comm::Entity {
+
+  anna::diameter::codec::Engine * a_codecEngine; // for automatic answers (failed-avp), write logs, etc.
+  bool a_balance; // Balance over entity servers instead of doing standard behaviour (first primary, secondary if fails, etc.). Default: false.
+  std::string a_sessionBasedModelsType;
+
+  void eventRequestRetransmission(const anna::diameter::comm::ClientSession *, anna::diameter::comm::Message*) throw();
+  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();
+
+public:
+
+  MyDiameterEntity() {
+    a_codecEngine = NULL;
+    a_balance = false;
+    a_sessionBasedModelsType = "SessionIdLowPart";
+  }
+
+  ProgrammedAnswers a_reactingAnswers;
+  void setCodecEngine(anna::diameter::codec::Engine *codecEngine) throw() { a_codecEngine = codecEngine; a_reactingAnswers.setCodecEngine(codecEngine); }
+  ProgrammedAnswers *getReactingAnswers() throw() { return (ProgrammedAnswers *)&a_reactingAnswers; }
+
+  // Additional configuration parameters:
+  void setSessionBasedModelsType(const std::string &type) throw() { a_sessionBasedModelsType = type; }
+  void setBalance(bool balance) throw() { a_balance = balance; }
+  const std::string & getSessionBasedModelsType() const throw() { return a_sessionBasedModelsType; }
+  bool getBalance() const throw() { return a_balance; }
+};
+
+#endif