Author: sayer
Date: 2009-03-11 03:13:02 +0100 (Wed, 11 Mar 2009)
New Revision: 1308
Modified:
trunk/apps/dsm/DSM.cpp
trunk/apps/dsm/DSM.h
Log:
add DI API: postDSMEvent
Example (with direct_export=dsm;monitoring):
s.postDSMEvent(s.list()[0], [["action", "kick"]])
transition "DI xmlrpc kick event" room - eventTest(#action==kick) / stop(true)
-> end;
Modified: trunk/apps/dsm/DSM.cpp
===================================================================
--- trunk/apps/dsm/DSM.cpp 2009-03-11 01:43:30 UTC (rev 1307)
+++ trunk/apps/dsm/DSM.cpp 2009-03-11 02:13:02 UTC (rev 1308)
@@ -30,17 +30,18 @@
#include "AmPlugIn.h"
#include "log.h"
#include "AmConfigReader.h"
+#include "AmSessionContainer.h"
+
#include "DSMDialog.h"
#include "DSMChartReader.h"
#include <string>
#include <fstream>
-
#define MOD_NAME "dsm"
-// session creator export
-extern "C" void* session_factory_create() {
+extern "C" void* plugin_class_create()
+{
return DSMFactory::instance();
}
@@ -59,7 +60,7 @@
bool DSMFactory::RunInviteEvent;
DSMFactory::DSMFactory(const string& _app_name)
- : AmSessionFactory(_app_name),
+ : AmSessionFactory(_app_name),AmDynInvokeFactory(_app_name),
loaded(false)
{
}
@@ -291,3 +292,27 @@
return s;
}
+
+void DSMFactory::invoke(const string& method, const AmArg& args,
+ AmArg& ret)
+{
+ if(method == "postDSMEvent"){
+ assertArgCStr(args.get(0))
+
+ DSMEvent* ev = new DSMEvent();
+ for (size_t i=0;i<args[1].size();i++)
+ ev->params[args[1][i][0].asCStr()] = args[1][i][1].asCStr();
+
+ if (AmSessionContainer::instance()->postEvent(args.get(0).asCStr(), ev)) {
+ ret.push(AmArg(200));
+ ret.push(AmArg("OK"));
+ } else {
+ ret.push(AmArg(404));
+ ret.push(AmArg("Session not found"));
+ }
+
+ } else if(method == "_list"){
+ ret.push(AmArg("postDSMEvent"));
+ } else
+ throw AmDynInvoke::NotImplemented(method);
+}
Modified: trunk/apps/dsm/DSM.h
===================================================================
--- trunk/apps/dsm/DSM.h 2009-03-11 01:43:30 UTC (rev 1307)
+++ trunk/apps/dsm/DSM.h 2009-03-11 02:13:02 UTC (rev 1308)
@@ -46,7 +46,9 @@
class DSMModule;
/** \brief Factory for announcement sessions */
class DSMFactory
- : public AmSessionFactory
+ : public AmSessionFactory,
+ public AmDynInvoke,
+ public AmDynInvokeFactory
{
AmPromptCollection prompts;
DSMStateDiagramCollection diags;
@@ -73,6 +75,13 @@
AmSession* onInvite(const AmSipRequest& req);
AmSession* onInvite(const AmSipRequest& req,
AmArg& session_params);
+ // DI
+ // DI factory
+ AmDynInvoke* getInstance() { return instance(); }
+ // DI API
+ void invoke(const string& method,
+ const AmArg& args, AmArg& ret);
+
};
#endif
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev