Module: sems
Branch: master
Commit: 6acd834aa6c59ec2ab8256027f830af907293085
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=6acd834aa6c59ec2ab8256027f830af907293085

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Mon Sep 20 17:31:01 2010 +0200

Session Timer support for DSM

configurable in dsm.conf, by default off

---

 apps/dsm/DSM.cpp      |   31 +++++++++++++++++++++++++++++--
 apps/dsm/DSM.h        |    4 ++++
 apps/dsm/etc/dsm.conf |   35 +++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/apps/dsm/DSM.cpp b/apps/dsm/DSM.cpp
index 9b7c91d..47d9448 100644
--- a/apps/dsm/DSM.cpp
+++ b/apps/dsm/DSM.cpp
@@ -80,7 +80,8 @@ string DSMFactory::MonSelectFallback;
 
 DSMFactory::DSMFactory(const string& _app_name)
   : AmSessionFactory(_app_name),AmDynInvokeFactory(_app_name),
-    loaded(false)
+    loaded(false),
+    session_timer_f(NULL)
 {
   AmEventDispatcher::instance()->addEventQueue("dsm", this);
 
@@ -118,7 +119,6 @@ int DSMFactory::onLoad()
     return 0;
   loaded = true;
 
-  AmConfigReader cfg;
   if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
     return -1;
  
@@ -260,6 +260,16 @@ int DSMFactory::onLoad()
       closedir(dir);
     }
   }
+
+  if(cfg.hasParameter("enable_session_timer") &&
+     (cfg.getParameter("enable_session_timer") == string("yes")) ){
+    DBG("enabling session timers\n");
+    session_timer_f = AmPlugIn::instance()->getFactory4Seh("session_timer");
+    if(session_timer_f == NULL){
+      ERROR("Could not load the session_timer module: disabling session 
timers.\n");
+    }
+  }
+
   return 0;
 }
 
@@ -488,6 +498,23 @@ bool DSMFactory::loadConfig(const string& conf_file_name, 
const string& conf_nam
 
 void DSMFactory::prepareSession(DSMCall* s) {
   s->setPromptSets(prompt_sets);
+  setupSessionTimer(s);
+}
+
+void DSMFactory::setupSessionTimer(AmSession* s) {
+  if (NULL != session_timer_f) {
+
+    AmSessionEventHandler* h = session_timer_f->getHandler(s);
+    if (NULL == h)
+      return;
+
+    if(h->configure(cfg)){
+      ERROR("Could not configure the session timer: disabling session 
timers.\n");
+      delete h;
+    } else {
+      s->addHandler(h);
+    }
+  }
 }
 
 void DSMFactory::addVariables(DSMCall* s, const string& prefix,
diff --git a/apps/dsm/DSM.h b/apps/dsm/DSM.h
index 59a6184..c2a0677 100644
--- a/apps/dsm/DSM.h
+++ b/apps/dsm/DSM.h
@@ -91,6 +91,7 @@ class DSMFactory
   DSMFactory(const string& _app_name);
   ~DSMFactory();
   bool loaded;
+  AmConfigReader cfg;
 
   int preloadModules(AmConfigReader& cfg, string& res, const string& ModPath);
   bool loadConfig(const string& conf_file_name, const string& conf_name, 
@@ -122,6 +123,9 @@ class DSMFactory
   void registerApplication(const AmArg& args, AmArg& ret);
   void loadConfig(const AmArg& args, AmArg& ret);
 
+  AmSessionEventHandlerFactory* session_timer_f;
+  void setupSessionTimer(AmSession* s);
+
 public:
   static DSMFactory* instance();
 
diff --git a/apps/dsm/etc/dsm.conf b/apps/dsm/etc/dsm.conf
index a295b8e..e13775b 100644
--- a/apps/dsm/etc/dsm.conf
+++ b/apps/dsm/etc/dsm.conf
@@ -142,3 +142,38 @@ 
load_prompts=/usr/local/etc/sems/dsm_in_prompts.conf,/usr/local/etc/sems/dsm_out
 #   and additional configuration variables (as script variables)
 #
 # conf_dir=/usr/local/etc/sems/dsm/
+
+
+###############################################################
+# RFC4028 Session Timer
+#
+
+# - enables the session timer ([yes,no]; default: no)
+#
+# enable_session_timer=yes
+
+# - set the "Session-Expires" parameter for the session timer.
+#
+# session_expires=240
+
+# - set the "Min-SE" parameter for the session timer.
+#
+# minimum_timer=90
+
+# session refresh (Session Timer, RFC4028) method
+#
+# INVITE                 - use re-INVITE
+# UPDATE                 - use UPDATE
+# UPDATE_FALLBACK_INVITE - use UPDATE if indicated in Allow, re-INVITE 
otherwise
+#
+# Default: UPDATE_FALLBACK_INVITE
+#
+# Note: Session Timers are only supported in some applications
+#
+#session_refresh_method=UPDATE
+
+# accept_501_reply - accept 501 reply as successful refresh? [yes|no]
+#
+# Default: yes
+#
+#accept_501_reply=no

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to