1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
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 //
10 #include <anna/diameter.comm/Timer.hpp>
11 #include <anna/diameter.comm/Response.hpp>
12 #include <anna/diameter.comm/Session.hpp>
13 #include <anna/diameter.comm/LocalServer.hpp>
15 #include <anna/core/tracing/Logger.hpp>
21 void diameter::comm::Timer::expire(anna::timex::Engine*)
22 throw(anna::RuntimeException) {
23 Response* response = NULL;
24 Session* session = NULL;
25 LocalServer* localServer = NULL;
28 case Type::ResponseExpiration:
29 response = getResponse();
30 response->setResultCode(Response::ResultCode::Timeout);
31 session = response->getSession();
33 string msg("anna::diameter::comm::Timer::expire | Response: ");
34 msg += response->asString();
35 anna::Logger::debug(msg, ANNA_FILE_LOCATION);
38 session->expireResponse(response);
40 case Type::SessionUnbind:
41 session = getSession();
45 string msg("anna::diameter::comm::Timer::expire | Session (ending): ");
46 msg += session->asString();
47 anna::Logger::debug(msg, ANNA_FILE_LOCATION);
50 //session->setOnDisconnect(Session::OnDisconnect::IgnorePendings);
51 session->unbind(true /* immediate */);
53 // La client-session desaparecio (hice un closeSession)
54 LOGDEBUG(anna::Logger::debug("anna::diameter::comm::Timer::expire | Session missing", ANNA_FILE_LOCATION));
58 case Type::SessionRecover:
59 session = getSession();
63 string msg("anna::diameter::comm::Timer::expire | Session (recovering): ");
64 msg += session->asString();
65 anna::Logger::debug(msg, ANNA_FILE_LOCATION);
68 session->setState(Session::State::Bound);
70 // La client-session desaparecio (hice un closeSession)
71 LOGDEBUG(anna::Logger::debug("anna::diameter::comm::Timer::expire | Session missing", ANNA_FILE_LOCATION));
75 case Type::LocalServerAttach:
76 localServer = getLocalServer();
80 string msg("anna::diameter::comm::Timer::expire | LocalServer (attach retry)");
81 //msg += localServer->asString();
82 anna::Logger::debug(msg, ANNA_FILE_LOCATION);
85 localServer->attach();
87 // LocalServer desaparecio (hice un closeLocalServer)
88 LOGDEBUG(anna::Logger::debug("anna::diameter::comm::Timer::expire | LocalServer missing", ANNA_FILE_LOCATION));
95 const char* diameter::comm::Timer::asText(const Type::_v type)
97 static const char* text [] = { "ResponseExpiration", "SessionUnbind", "SessionRecover", "LocalServerAttach" };
101 string diameter::comm::Timer::asString() const
103 string result("anna::diameter::comm::Timer { ");
104 result += anna::timex::Transaction::asString();
106 result += asText(a_type);
109 case Type::ResponseExpiration: {
110 const Response* response = getResponse();
112 if(response != NULL) {
114 result += response->asString();
116 result += " | Response: <null>";
120 case Type::SessionUnbind:
121 case Type::SessionRecover: {
122 const Session *session = getSession();
124 if(session != NULL) {
126 result += session->asString();
128 result += " | Session: <null>"; // puede ocurrir ??
132 case Type::LocalServerAttach: {
133 const LocalServer *localServer = getLocalServer();
135 if(localServer != NULL) {
137 result += localServer->asString();
139 result += " | LocalServer: <null>"; // puede ocurrir ??
145 return result += " }";