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

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

Session Timer support for webconference app

configurable in webconference.conf, by default off

---

 apps/webconference/WebConference.cpp      |   54 +++++++++++++++++++++++-----
 apps/webconference/WebConference.h        |    7 +++-
 apps/webconference/etc/webconference.conf |   36 ++++++++++++++++++-
 3 files changed, 85 insertions(+), 12 deletions(-)

diff --git a/apps/webconference/WebConference.cpp 
b/apps/webconference/WebConference.cpp
index 1925b9b..be28521 100644
--- a/apps/webconference/WebConference.cpp
+++ b/apps/webconference/WebConference.cpp
@@ -51,7 +51,8 @@ WebConferenceFactory::WebConferenceFactory(const string& 
_app_name)
     configured(false),
     use_direct_room(false),
     direct_room_strip(0),
-    stats(NULL)
+    stats(NULL),
+    session_timer_f(NULL)
 {
   if (NULL == _instance) {
     _instance = this;
@@ -83,7 +84,6 @@ int WebConferenceFactory::load()
     return 0;
   configured = true;
 
-  AmConfigReader cfg;
   if(cfg.loadFile(AmConfig::ModConfigPath + string(APP_NAME)+ ".conf"))
     return -1;
 
@@ -209,6 +209,15 @@ int WebConferenceFactory::load()
     }
   }
 
+  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;
 }
 
@@ -285,24 +294,47 @@ string WebConferenceFactory::getAccessUri(const string& 
room) {
   return res;
 }
 
+void WebConferenceFactory::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);
+    }
+  }
+}
+
 // incoming calls 
 AmSession* WebConferenceFactory::onInvite(const AmSipRequest& req)
 {
-  if (use_direct_room) {
-    if (!regexec(&direct_room_re, req.user.c_str(), 0,0,0)) {
+  if (NULL != session_timer_f) {
+    if (!session_timer_f->onInvite(req, cfg))
+      return NULL;
+  }
+
+  WebConferenceDialog* w;
+
+  if (use_direct_room && !regexec(&direct_room_re, req.user.c_str(), 0,0,0)) {
       string room = req.user;
       if (room.length() > direct_room_strip) 
        room = room.substr(direct_room_strip);
       DBG("direct room access match. connecting to room '%s'\n", 
          room.c_str());
-      WebConferenceDialog* w = 
-       new WebConferenceDialog(prompts, getInstance(), room);
 
+      w = new WebConferenceDialog(prompts, getInstance(), room);
       w->setUri(getAccessUri(room));
-      return w;
-    }
-  } 
-  return new WebConferenceDialog(prompts, getInstance(), NULL);
+
+  } else {
+    w = new WebConferenceDialog(prompts, getInstance(), NULL);
+  }
+  setupSessionTimer(w);
+  return w;
 }
 
 // outgoing calls 
@@ -331,6 +363,8 @@ AmSession* WebConferenceFactory::onInvite(const 
AmSipRequest& req,
 
   s->setUri(getAccessUri(req.user));
 
+  setupSessionTimer(s);
+
   return s;
 }
 
diff --git a/apps/webconference/WebConference.h 
b/apps/webconference/WebConference.h
index 7515315..b97c4ac 100644
--- a/apps/webconference/WebConference.h
+++ b/apps/webconference/WebConference.h
@@ -82,13 +82,16 @@ class WebConferenceFactory
 
   int room_sweep_cnt;
 
+  AmSessionEventHandlerFactory* session_timer_f;
+
   // for DI 
   static WebConferenceFactory* _instance;
   bool configured;
+  AmConfigReader cfg;
 
   string getServerInfoString();
   string getRandomPin();
-  /** returns NULL if adminpin wrong */
+  /** @return NULL if adminpin wrong */
   ConferenceRoom* getRoom(const string& room, 
                          const string& adminpin);
   void postConfEvent(const AmArg& args, AmArg& ret,
@@ -110,6 +113,8 @@ class WebConferenceFactory
   void sweepRooms();
 
   int load();
+  
+  void setupSessionTimer(AmSession* s);
 
 public:
   static string DigitsDir;
diff --git a/apps/webconference/etc/webconference.conf 
b/apps/webconference/etc/webconference.conf
index 3f53ea3..c81f33d 100644
--- a/apps/webconference/etc/webconference.conf
+++ b/apps/webconference/etc/webconference.conf
@@ -111,4 +111,38 @@ stats_dir=/var/log/sems-webconference/
 #
 # list of rooms that are openend at server startup
 #
-# predefined_rooms=discussion:some_pwd;support:other_pwd;
\ No newline at end of file
+# predefined_rooms=discussion:some_pwd;support:other_pwd;
+
+###############################################################
+# 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