Fixes and improvs. Basic DRA feature.
[anna.git] / example / diameter / launcher / RealmNode.cpp
index c61bbe4..d3a2b89 100644 (file)
 #include <anna/xml/Compiler.hpp>
 
 // Process
-#include "RealmNode.hpp"
-#include "MyDiameterEngine.hpp"
-
+#include <RealmNode.hpp>
+#include <MyDiameterEngine.hpp>
 
+namespace anna {
+  namespace diameter {
+    namespace stack {
+      class Dictionary;
+    }
+  }
+}
 
-RealmNode::RealmNode(const std::string &originRealm, unsigned int applicationId, anna::diameter::codec::Engine *codecEngine) :
-  a_originRealm(originRealm), a_applicationId(applicationId), a_codecEngine(codecEngine) {
+RealmNode::RealmNode(const std::string &originRealm, anna::diameter::codec::Engine *codecEngine, const anna::diameter::stack::Dictionary *baseProtocolDictionary) :
+  a_originRealm(originRealm), a_codecEngine(codecEngine) {
 
   std::string commEngineName = a_originRealm + "_DiameterCommEngine";
-  a_commEngine = new MyDiameterEngine(commEngineName.c_str());
+  a_commEngine = new MyDiameterEngine(commEngineName.c_str(), baseProtocolDictionary);
   a_commEngine->setAutoBind(false);  // allow to create client-sessions without binding them, in order to set timeouts.
-  a_commEngine->setBaseProtocolCodecEngine(getCodecEngine());
 
   a_logFile = "";
   a_burstLogFile = "";
@@ -56,7 +61,7 @@ RealmNode::RealmNode(const std::string &originRealm, unsigned int applicationId,
 }
 
 
-void RealmNode::createEntity(const std::string &entityRepresentation, const anna::Millisecond &bindTimeout, const anna::Millisecond &applicationTimeout) throw() {
+void RealmNode::createEntity(const std::string &entityRepresentation, const anna::Millisecond &bindTimeout, const anna::Millisecond &applicationTimeout) throw(anna::RuntimeException) {
 
   anna::socket_v servers = anna::functions::getSocketVectorFromString(entityRepresentation);
   std::string entityDescription = "Launcher diameter entity for "; entityDescription += a_originRealm;
@@ -365,6 +370,9 @@ bool RealmNode::sendBurstMessage(bool anyway) throw() {
 }
 
 std::string RealmNode::lookBurst(int order) const throw() {
+
+  if (order == -1) order = a_burstDeliveryIt->first;
+
   std::string result = "No message found for order provided (";
   result += anna::functions::asString(order);
   result += ")";
@@ -399,7 +407,6 @@ throw() {
   anna::xml::Node* result = parent->createChild("RealmNode");
 
   result->createAttribute("OriginRealm", a_originRealm);
-  result->createAttribute("ApplicationId", a_applicationId);
   result->createAttribute("LogFile", a_logFile);
   result->createAttribute("SplitLog", a_splitLog ? "yes" : "no");
   result->createAttribute("DetailedLog", a_detailedLog ? "yes" : "no");