10#include <CXX/Objects.hxx>
11#include <CXX/Extensions.hxx>
31#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
49 std::unique_ptr<Py::Module> pyModule =
loadModule(mRouteScript);
55 if(pyModule->getDict().hasKey(
"on_load"))
57 DebugLog(<<
"found on_load method, trying to invoke it...");
61 pyModule->callMemberFunction(
"on_load");
63 catch (
const Py::Exception& ex)
65 DebugLog(<<
"call to on_load method failed: " << Py::value(ex));
71 mPyModule = std::move(pyModule);
73 mAction = mPyModule->getAttr(
"provide_route");
74 if(mPyModule->getDict().hasKey(
"on_message"))
76 mMessageHandlerAction = mPyModule->getAttr(
"on_message");
85 DebugLog(<<
"PyRoutePlugin: init called");
89 ErrLog(<<
"proxyConfig == 0, aborting");
94 mRouteScript = proxyConfig->
getConfigData(
"PyRouteScript",
"",
true);
97 ErrLog(<<
"PyRoutePath not specified in config, aborting");
100 if(mRouteScript.
empty())
102 ErrLog(<<
"PyRouteScript not specified in config, aborting");
111 int numPyRouteWorkerThreads = proxyConfig->
getConfigInt(
"PyRouteNumWorkerThreads", 2);
112 std::unique_ptr<Worker> worker(
new PyRouteWorker(*
this, mAction, mMessageHandlerAction));
113 mDispatcher.reset(
new Dispatcher(std::move(worker), &sipStack, numPyRouteWorkerThreads));
123 DebugLog(<<
"PyRoutePlugin: onRequestProcessorChainPopulated called");
135 DebugLog(<<
"PyRoutePlugin: onResponseProcessorChainPopulated called");
140 DebugLog(<<
"PyRoutePlugin: onTargetProcessorChainPopulated called");
145 DebugLog(<<
"PyRoutePlugin: onReload called");
150 std::unique_ptr<Py::Module> mPyModule;
151 Py::Callable mAction;
152 Py::Callable mMessageHandlerAction;
153 std::unique_ptr<Dispatcher> mDispatcher;
154 std::shared_ptr<PyRouteMessageHandler> mMessageHandler;
163 return std::make_shared<PyRoutePlugin>();
PluginDescriptor reproPluginDesc
static std::shared_ptr< resip::Plugin > instantiate()
virtual bool init(SipStack &sipStack, ProxyConfig *proxyConfig) override
virtual void onTargetProcessorChainPopulated(ProcessorChain &chain) override
virtual void onResponseProcessorChainPopulated(ProcessorChain &chain) override
virtual void onRequestProcessorChainPopulated(ProcessorChain &chain) override
virtual void onReload() override
virtual bool onStartup() override
void insertProcessor(std::unique_ptr< Processor > rp)
int getConfigInt(const resip::Data &name, int defaultValue) const
resip::Data getConfigData(const resip::Data &name, const resip::Data &defaultValue, bool useDefaultIfEmpty=false) const
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
bool empty() const noexcept
Checks whether the Data is empty.
A generic thread-bank class.
virtual std::unique_ptr< Py::Module > loadModule(const resip::Data &moduleName)
virtual bool init(const resip::Data &pyPath)
This is the primary point of interaction between the app-layer and the stack.
void addTransportSipMessageLoggingHandler(std::shared_ptr< Transport::SipMessageLoggingHandler > handler)
Used by the application to provide a handler that will get called for all inbound and outbound SIP me...
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
#define REPRO_DSO_PLUGIN_API_VERSION