diff --git a/apps/sst_b2b/SSTB2B.cpp b/apps/sst_b2b/SSTB2B.cpp index 2e046935..01df81be 100644 --- a/apps/sst_b2b/SSTB2B.cpp +++ b/apps/sst_b2b/SSTB2B.cpp @@ -69,6 +69,8 @@ int SSTB2BFactory::onLoad() AmSession* SSTB2BFactory::onInvite(const AmSipRequest& req) { + if (!session_timer_fact->onInvite(req, cfg)) + return NULL; SSTB2BDialog* b2b_dlg = new SSTB2BDialog(); AmSessionEventHandler* h = session_timer_fact->getHandler(b2b_dlg); @@ -76,6 +78,7 @@ AmSession* SSTB2BFactory::onInvite(const AmSipRequest& req) ERROR("could not get a session timer event handler\n"); throw AmSession::Exception(500,"Server internal error"); } + if(h->configure(cfg)){ ERROR("Could not configure the session timer: disabling session timers.\n"); delete h; diff --git a/core/AmApi.cpp b/core/AmApi.cpp index d15510cc..ac9b6df5 100644 --- a/core/AmApi.cpp +++ b/core/AmApi.cpp @@ -94,9 +94,10 @@ AmSessionEventHandlerFactory::AmSessionEventHandlerFactory(const string& name) } bool AmSessionEventHandlerFactory::onInvite(const AmSipRequest& req, - AmArg& session_params) { + AmArg& session_params, + AmConfigReader& cfg) { WARN("discarding session parameters for new session.\n"); - return onInvite(req); + return onInvite(req, cfg); } // AmSIPEventHandler::AmSIPEventHandler(const string& name) diff --git a/core/AmApi.h b/core/AmApi.h index f9e76e98..dafbab2f 100644 --- a/core/AmApi.h +++ b/core/AmApi.h @@ -110,10 +110,10 @@ class AmSessionEventHandlerFactory: public AmPluginFactory virtual AmSessionEventHandler* getHandler(AmSession*)=0; /** - * @return true if session creation should be stopped + * @return false if session creation should be stopped */ - virtual bool onInvite(const AmSipRequest& req)=0; - virtual bool onInvite(const AmSipRequest& req, AmArg& session_params); + virtual bool onInvite(const AmSipRequest& req, AmConfigReader& cfg)=0; + virtual bool onInvite(const AmSipRequest& req, AmArg& session_params, AmConfigReader& cfg); }; /** \brief Interface for plugins to create sessions */ diff --git a/core/AmSession.h b/core/AmSession.h index 4e0e5cda..20c6d1f8 100644 --- a/core/AmSession.h +++ b/core/AmSession.h @@ -195,7 +195,8 @@ public: struct Exception { int code; string reason; - Exception(int c, string r) : code(c), reason(r) {} + string hdrs; + Exception(int c, string r, string h="") : code(c), reason(r), hdrs(h) {} }; /** diff --git a/core/AmSessionContainer.cpp b/core/AmSessionContainer.cpp index 0da7022b..5378f927 100644 --- a/core/AmSessionContainer.cpp +++ b/core/AmSessionContainer.cpp @@ -307,8 +307,8 @@ void AmSessionContainer::startSessionUAS(AmSipRequest& req) } } catch(const AmSession::Exception& e){ - ERROR("%i %s\n",e.code,e.reason.c_str()); - AmSipDialog::reply_error(req,e.code,e.reason); + ERROR("%i %s %s\n",e.code,e.reason.c_str(), e.hdrs.c_str()); + AmSipDialog::reply_error(req,e.code,e.reason, e.hdrs); } catch(const string& err){ ERROR("startSession: %s\n",err.c_str()); diff --git a/core/plug-in/echo/Echo.cpp b/core/plug-in/echo/Echo.cpp index a90e051a..7a39c088 100644 --- a/core/plug-in/echo/Echo.cpp +++ b/core/plug-in/echo/Echo.cpp @@ -76,10 +76,18 @@ int EchoFactory::onLoad() AmSession* EchoFactory::onInvite(const AmSipRequest& req) { + if (NULL != session_timer_f) { + if (!session_timer_f->onInvite(req, conf)) + return NULL; + } + AmSession* s = new EchoDialog(); if (NULL != session_timer_f) { + AmSessionEventHandler* h = session_timer_f->getHandler(s); + if (NULL == h) + return NULL; if(h->configure(conf)){ ERROR("Could not configure the session timer: disabling session timers.\n"); diff --git a/core/plug-in/session_timer/SessionTimer.cpp b/core/plug-in/session_timer/SessionTimer.cpp index 06e1c16c..0926d38c 100644 --- a/core/plug-in/session_timer/SessionTimer.cpp +++ b/core/plug-in/session_timer/SessionTimer.cpp @@ -37,11 +37,9 @@ int SessionTimerFactory::onLoad() return 0; } -bool SessionTimerFactory::onInvite(const AmSipRequest& req) +bool SessionTimerFactory::onInvite(const AmSipRequest& req, AmConfigReader& cfg) { - if(!checkSessionExpires(req)) - return true; - return false; + return checkSessionExpires(req, cfg); } @@ -127,11 +125,9 @@ bool SessionTimer::onSendReply(const AmSipRequest& req, return false; } - -/* Session Timer: -ssa */ -int SessionTimer::configure(AmConfigReader& conf) +int SessionTimer::configure(AmConfigReader& conf) { - if(session_timer_conf.readFromConfig(conf)) + if(!session_timer_conf.readFromConfig(conf)) return -1; session_interval = session_timer_conf.getSessionExpires(); @@ -152,22 +148,29 @@ int SessionTimer::configure(AmConfigReader& conf) * (