diff --git a/apps/dsm/DSMCoreModule.cpp b/apps/dsm/DSMCoreModule.cpp index 7d88f3e3..60cc39fd 100644 --- a/apps/dsm/DSMCoreModule.cpp +++ b/apps/dsm/DSMCoreModule.cpp @@ -74,6 +74,8 @@ DSMAction* DSMCoreModule::getAction(const string& from_str) { DEF_CMD("logVars", SCLogVarsAction); DEF_CMD("setTimer", SCSetTimerAction); + DEF_CMD("removeTimer", SCRemoveTimerAction); + DEF_CMD("removeTimers", SCRemoveTimersAction); DEF_CMD("setPrompts", SCSetPromptsAction); @@ -447,6 +449,61 @@ EXEC_ACTION_START(SCSetTimerAction) { } EXEC_ACTION_END; +EXEC_ACTION_START(SCRemoveTimerAction) { + + unsigned int timerid; + if (str2i(resolveVars(arg, sess, sc_sess, event_params), timerid)) { + ERROR("timer id '%s' not decipherable\n", + resolveVars(arg, sess, sc_sess, event_params).c_str()); + return false; + } + + DBG("removing timer %u\n", timerid); + AmDynInvokeFactory* user_timer_fact = + AmPlugIn::instance()->getFactory4Di("user_timer"); + + if(!user_timer_fact) { + ERROR("load sess_timer module for timers.\n"); + return false; + } + AmDynInvoke* user_timer = user_timer_fact->getInstance(); + if(!user_timer) { + ERROR("load sess_timer module for timers.\n"); + return false; + } + + AmArg di_args,ret; + di_args.push((int)timerid); + di_args.push(sess->getLocalTag().c_str()); + user_timer->invoke("removeTimer", di_args, ret); + +} EXEC_ACTION_END; + +EXEC_ACTION_START(SCRemoveTimersAction) { + + + DBG("removing timers for session %s\n", sess->getLocalTag().c_str()); + AmDynInvokeFactory* user_timer_fact = + AmPlugIn::instance()->getFactory4Di("user_timer"); + + if(!user_timer_fact) { + ERROR("load sess_timer module for timers.\n"); + return false; + } + AmDynInvoke* user_timer = user_timer_fact->getInstance(); + if(!user_timer) { + ERROR("load sess_timer module for timers.\n"); + return false; + } + + AmArg di_args,ret; + di_args.push(sess->getLocalTag().c_str()); + user_timer->invoke("removeUserTimers", di_args, ret); + +} EXEC_ACTION_END; + + + // TODO: replace with real expression matching TestDSMCondition::TestDSMCondition(const string& expr, DSMCondition::EventType evt) { diff --git a/apps/dsm/DSMCoreModule.h b/apps/dsm/DSMCoreModule.h index 43ffdd3e..63b1984e 100644 --- a/apps/dsm/DSMCoreModule.h +++ b/apps/dsm/DSMCoreModule.h @@ -77,6 +77,8 @@ DEF_ACTION_2P(SCSubStrAction); DEF_ACTION_1P(SCIncAction); DEF_ACTION_1P(SCClearAction); DEF_ACTION_2P(SCSetTimerAction); +DEF_ACTION_1P(SCRemoveTimerAction); +DEF_ACTION_1P(SCRemoveTimersAction); DEF_ACTION_2P(SCLogAction); DEF_ACTION_1P(SCLogVarsAction); DEF_ACTION_2P(SCGetVarAction); diff --git a/apps/dsm/doc/dsm_syntax.txt b/apps/dsm/doc/dsm_syntax.txt index 3a1f6052..e4a9bf5c 100644 --- a/apps/dsm/doc/dsm_syntax.txt +++ b/apps/dsm/doc/dsm_syntax.txt @@ -95,6 +95,8 @@ actions: setTimer(timer_id, timeout) e.g. setTimer(1, $timeout) + removeTimer(timer_id) + removeTimers() DI(factory, function [, params...]) e.g. DI(factory, function, $var_param, (int)int_param, "$str param", @select_par, ...)