Session Timer support for webconference app

configurable in webconference.conf, by default off
sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent 24b6f5163f
commit dd841fbf75

@ -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;
}

@ -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;

@ -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;
# 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

Loading…
Cancel
Save