73494b5c133099bc9b6962b0a60f60aac7e1a087
[anna.git] / example / diameter / launcher / MyDiameterEntity.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef example_diameter_launcher_MyDiameterEntity_hpp
10 #define example_diameter_launcher_MyDiameterEntity_hpp
11
12 // Project
13 #include <anna/diameter.comm/Entity.hpp>
14
15 // Process
16 #include <ProgrammedAnswers.hpp>
17
18 namespace anna {
19   namespace diameter {
20     namespace codec {
21       class Engine;
22     }
23   }
24 }
25
26 class MyDiameterEntity : public anna::diameter::comm::Entity {
27
28   bool a_balance; // Balance over entity servers instead of doing standard behaviour (first primary, secondary if fails, etc.). Default: false.
29   std::string a_sessionBasedModelsType;
30
31   void eventRequestRetransmission(const anna::diameter::comm::ClientSession *, anna::diameter::comm::Message*) throw();
32   void eventResponse(const anna::diameter::comm::Response&) throw(anna::RuntimeException);
33   void eventRequest(anna::diameter::comm::ClientSession *, const anna::DataBlock&) throw(anna::RuntimeException);
34   void eventUnknownResponse(anna::diameter::comm::ClientSession *, const anna::DataBlock&) throw(anna::RuntimeException);
35   void eventDPA(anna::diameter::comm::ClientSession *, const anna::DataBlock&) throw(anna::RuntimeException);
36
37   // Reimplementation
38   int readSocketId(const anna::diameter::comm::Message* message, int maxClientSessions) const throw();
39
40 public:
41
42   MyDiameterEntity() {
43     a_balance = false;
44     a_sessionBasedModelsType = "SessionIdLowPart";
45   }
46
47   ProgrammedAnswers a_reactingAnswers;
48   ProgrammedAnswers *getReactingAnswers() throw() { return (ProgrammedAnswers *)&a_reactingAnswers; }
49
50   // Additional configuration parameters:
51   void setSessionBasedModelsType(const std::string &type) throw() { a_sessionBasedModelsType = type; }
52   void setBalance(bool balance) throw() { a_balance = balance; }
53   const std::string & getSessionBasedModelsType() const throw() { return a_sessionBasedModelsType; }
54   bool getBalance() const throw() { return a_balance; }
55 };
56
57 #endif