mirror of https://github.com/sipwise/sems.git
git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@314 8eb893ce-cfd4-0310-b710-fb5ebe64c474sayer/1.4-spce2.6
parent
79aaf4685b
commit
e75cecf3d3
@ -0,0 +1,67 @@
|
||||
#include "AmPlugIn.h"
|
||||
#include "log.h"
|
||||
#include "AmUAC.h"
|
||||
|
||||
|
||||
#include "DIDial.h"
|
||||
|
||||
class DIDialFactory : public AmDynInvokeFactory
|
||||
{
|
||||
public:
|
||||
DIDialFactory(const string& name)
|
||||
: AmDynInvokeFactory(name) {}
|
||||
|
||||
AmDynInvoke* getInstance(){
|
||||
return DIDial::instance();
|
||||
}
|
||||
|
||||
int onLoad(){
|
||||
DBG("DIDial calling card accounting loaded.\n");
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
EXPORT_PLUGIN_CLASS_FACTORY(DIDialFactory,"di_dial");
|
||||
|
||||
DIDial* DIDial::_instance=0;
|
||||
|
||||
DIDial* DIDial::instance()
|
||||
{
|
||||
if(!_instance)
|
||||
_instance = new DIDial();
|
||||
return _instance;
|
||||
}
|
||||
|
||||
DIDial::DIDial() {
|
||||
}
|
||||
|
||||
DIDial::~DIDial() { }
|
||||
|
||||
void DIDial::invoke(const string& method, const AmArgArray& args, AmArgArray& ret)
|
||||
{
|
||||
if(method == "dial"){
|
||||
ret.push(dialout(args.get(0).asCStr(),
|
||||
args.get(1).asCStr(),
|
||||
args.get(2).asCStr(),
|
||||
args.get(3).asCStr()).c_str());
|
||||
} else if(method == "help"){
|
||||
ret.push("dial <application> <user> <from> <to>\n");
|
||||
} else
|
||||
throw AmDynInvoke::NotImplemented(method);
|
||||
}
|
||||
|
||||
string DIDial::dialout(const string& application,
|
||||
const string& user,
|
||||
const string& from,
|
||||
const string& to) {
|
||||
DBG("dialout application '%s', user '%s', from '%s', to '%s'",
|
||||
application.c_str(), user.c_str(), from.c_str(), to.c_str());
|
||||
|
||||
AmSession* s = AmUAC::dialout(user.c_str(), application, to,
|
||||
"<" + from + ">", from, "<" + to + ">");
|
||||
if (s)
|
||||
return s->getLocalTag();
|
||||
else
|
||||
return "<failed>";
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#include "AmApi.h"
|
||||
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
class DIDial : public AmDynInvoke
|
||||
|
||||
{
|
||||
string dialout(const string& application,
|
||||
const string& user,
|
||||
const string& from,
|
||||
const string& to);
|
||||
|
||||
static DIDial* _instance;
|
||||
public:
|
||||
DIDial();
|
||||
~DIDial();
|
||||
static DIDial* instance();
|
||||
void invoke(const string& method, const AmArgArray& args, AmArgArray& ret);
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
plug_in_name = di_dial
|
||||
|
||||
module_ldflags =
|
||||
module_cflags =
|
||||
|
||||
COREPATH ?=../../../core
|
||||
include $(COREPATH)/plug-in/Makefile.app_module
|
@ -0,0 +1,30 @@
|
||||
dialout over DI interface
|
||||
|
||||
this example lets you trigger creating sessions over
|
||||
the DI interface. With the DI interface exportde to UDP
|
||||
in the stats module, you can for example make a simple load
|
||||
generator test tool.
|
||||
|
||||
DI Interface is like this
|
||||
method: "dial"
|
||||
params:
|
||||
0 - string application
|
||||
1 - string user
|
||||
2 - string from
|
||||
3 - string to
|
||||
|
||||
method: "help"
|
||||
params: none
|
||||
return help string
|
||||
e.g. get help with query_stats -c DI di_dial help
|
||||
|
||||
The following line would for example place a call every
|
||||
second using announcement app from local user 123 to sip:ann@10.0.0.45
|
||||
|
||||
while true; do \
|
||||
../../../core/plug-in/stats/query_stats -c DI di_dial \
|
||||
dial announcement 123 sip:ann@10.0.0.45 sip:123@83.246.121.43; \
|
||||
sleep 1; \
|
||||
done
|
||||
|
||||
Please dont use SEMS for SPIT.
|
@ -0,0 +1 @@
|
||||
while true; do ./query_stats -c DI di_dial dial announcement 123 sip:ann@10.0.0.45 sip:123@83.246.121.43; sleep 1; done
|
Loading…
Reference in new issue