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/Response.hpp>
11 #include <anna/diameter.comm/Message.hpp>
12 #include <anna/diameter.comm/TimerManager.hpp>
13 #include <anna/diameter/defines.hpp>
14 #include <anna/diameter/helpers/helpers.hpp>
16 #include <anna/core/functions.hpp>
17 #include <anna/core/tracing/Logger.hpp>
24 diameter::comm::Response::response_pool diameter::comm::Response::st_responses;
26 //----------------------------------------------------------------------------------------
27 // Se invocan desde diameter::comm::Session
28 //----------------------------------------------------------------------------------------
29 diameter::comm::Response* diameter::comm::Response::instance(const ClassCode::_v & classCode, const HopByHop hopByHop)
30 throw(anna::RuntimeException) {
31 diameter::comm::Response* result = st_responses.create();
32 result->a_classCode = classCode;
33 result->a_hopByHop = hopByHop;
36 string msg("anna::diameter::comm::Response::instance | ");
37 msg += result->asString();
38 anna::Logger::debug(msg, ANNA_FILE_LOCATION);
43 void diameter::comm::Response::release(diameter::comm::Response* response)
46 st_responses.release(response);
47 } catch(anna::RuntimeException& ex) {
52 diameter::comm::Response::Response() :
53 a_classCode(ClassCode::Undefined),
60 void diameter::comm::Response::clear()
62 a_resultCode = ResultCode::Undefined;
68 void diameter::comm::Response::activateTimer()
69 throw(anna::RuntimeException) {
70 a_timer = TimerManager::instantiate().createTimer(this);
73 void diameter::comm::Response::cancelTimer()
77 TimerManager::instantiate().cancelTimer(a_timer);
78 } catch(anna::RuntimeException& ex) {
86 const char* diameter::comm::Response::asText(const ResultCode::_v rc)
88 static const char* text [] = { "Undefined", "Success", "Timeout", "DiameterUnavailable" };
92 //bool diameter::comm::Response::isKeepAlive() const
95 // if (a_request->getCommandId() == diameter::helpers::base::COMMANDID__Device_Watchdog_Request)
102 string diameter::comm::Response::asString() const
104 string result("diameter::comm::Response { ClassCode: ");
105 result += ClassCode::asText(a_classCode);
106 result += anna::functions::asString(" | HopByHop: %u", a_hopByHop);
107 result += " | ResultCode: ";
108 result += asText(a_resultCode);
109 return result += " }";