ANNA Suite  2020b
Multipurpose development suite for Telco applications
ServerSession.hpp
Go to the documentation of this file.
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 anna_diameter_comm_ServerSession_hpp
10 #define anna_diameter_comm_ServerSession_hpp
11 
12 
13 // STL
14 #include <string>
15 
17 #include <anna/core/util/defines.hpp> // U32
19 
25 
26 
27 namespace anna {
28 class DataBlock;
29 namespace timex {
30 class Engine;
31 }
32 
33 namespace comm {
34 class ClientSocket;
35 }
36 }
37 
38 
39 namespace anna {
40 
41 namespace diameter {
42 
43 namespace comm {
44 
45 
46 class LocalServer;
47 class OriginHost;
48 
49 
53 class ServerSession : public Session {
54 public:
55 
56  ServerSession();
57 
58 
59  /* virtual */void initialize() ;
60 
65 
71  void setAllowedInactivityTime(const anna::Millisecond & allowedInactivityTime) ;
72 
77  /* virtual */const std::string& getAddress() const ;
78 
83  /* virtual */int getPort() const ;
84 
88  int getKey() const { return getSocketId(); }
89 
94  LocalServer *getParent() { return a_parent; }
95 
96 
101  void setClientSocket(anna::comm::ClientSocket *clientSocket) ;
102 
107  anna::comm::ClientSocket *getClientSocket() { return a_clientSocket; }
108 
109  /* virtual */const Response* send(const Message* message) noexcept(false);
110  /* virtual */bool unbind(bool forceDisconnect /* se usa en timer, para el actionTimer del tipo SessionUnbind, etc. */ = false) noexcept(false); // returns true if done at call time (no pendings or ignore pendings, except Disconnecting state by mean DPR/DPA)
111 
112 
117  /* virtual */std::string asString() const ;
118 
119 
125  /* virtual */anna::xml::Node* asXML(anna::xml::Node* parent) const ;
126 
127 protected:
128 
129  // Deprecated state
131 
132 private:
133 
134  // Receiver factory
135  ReceiverFactoryImpl<ServerSession, ServerSessionReceiver> a_receiverFactory;
136 
137  // Parent information
138  LocalServer *a_parent;
139 
140  // Client Socket
141  anna::comm::ClientSocket *a_clientSocket;
142 
143  /* virtual */void expire(anna::timex::Engine *timeController) noexcept(false);
144 
145  // Activity:
146  /* virtual */void updateIncomingActivityTime() ;
147  /* virtual */void updateOutgoingActivityTime() ;
148  void countSendings(const diameter::CommandId & cid, unsigned int aid, bool ok) ;
149 
150  // Handlers:
156  void eventPeerShutdown() ;
157 
163  void eventRequestRetransmission(Message *request) ;
164 
171  void eventResponse(const Response& response, const anna::diameter::comm::OriginHost *myNode) noexcept(false);
172 
179  void eventRequest(const anna::DataBlock& request, const anna::diameter::comm::OriginHost *myNode) noexcept(false);
180  //void eventRequest(const Message& request) noexcept(false);
181 
188  void eventUnknownResponse(const anna::DataBlock& response, const anna::diameter::comm::OriginHost *myNode) noexcept(false);
189 
196  void eventDPA(const anna::DataBlock& response, const anna::diameter::comm::OriginHost *myNode) noexcept(false);
197 
198 
199 
203  /* virtual */void receive(const anna::comm::Message& message) noexcept(false);
204  /* virtual */void finalize() ;
205 
206  /* virtual */void expireResponse(Response*) ;
207 
208  anna::U32 getAuthApplicationIdFromCER(const anna::DataBlock &cer, bool &found) const;
209 
210  void sendCEA(const Engine*, const anna::DataBlock &cerDataBlock) noexcept(false);
211  void sendDWA(const Engine*, const anna::DataBlock &dwrDataBlock) noexcept(false);
212 
213 
215  friend class LocalServer;
216  friend class Engine;
217  friend class ServerSessionReceiver;
218 };
219 
220 }
221 }
222 }
223 
224 #endif
225 
LocalServer * getParent()
Definition: ServerSession.hpp:94
Definition: Millisecond.hpp:24
Definition: Engine.hpp:102
Definition: Node.hpp:56
Definition: Timer.hpp:30
Definition: ClientSocket.hpp:38
Definition: OriginHost.hpp:41
uint32_t U32
Definition: defines.hpp:75
int getKey() const
Definition: ServerSession.hpp:88
Definition: Message.hpp:26
Definition: Response.hpp:44
Definition: Message.hpp:45
Definition: ServerSession.hpp:53
Definition: LocalServer.hpp:55
bool a_deprecated
Definition: ServerSession.hpp:130
anna::comm::ClientSocket * getClientSocket()
Definition: ServerSession.hpp:107
Definition: app.hpp:12
static const anna::Millisecond DefaultAllowedInactivityTime
Definition: ServerSession.hpp:64
Definition: ServerSessionReceiver.hpp:35
Definition: Engine.hpp:62
std::pair< U24, bool > CommandId
Definition: defines.hpp:32
Definition: Session.hpp:55
Definition: DataBlock.hpp:24