reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
PyRouteWorker.hxx
Go to the documentation of this file.
1#ifndef PYROUTE_WORKER_HXX
2#define PYROUTE_WORKER_HXX
3
4#include <memory>
5
6/* Using the PyCXX API for C++ Python integration
7 * It is extremely convenient and avoids the need to write boilerplate
8 * code for handling the Python reference counts.
9 * It is licensed under BSD terms compatible with reSIProcate */
10#include <Python.h>
11#include <CXX/Objects.hxx>
12
13#include "rutil/Logger.hxx"
15#include "repro/Plugin.hxx"
16#include "repro/Processor.hxx"
20
22
23namespace repro
24{
25
27{
28 public:
30 const resip::Data& tid,
32 resip::SipMessage& message);
33
34 virtual ~PyRouteWork();
35
39 std::vector<resip::Data> mTargets;
40
41 virtual PyRouteWork* clone() const;
42
43 virtual EncodeStream& encode(EncodeStream& ostr) const;
45
46 bool hasResponse() { return mResponseCode >= 0; };
47};
48
50{
51 public:
53
55
56 std::shared_ptr<resip::SipMessage> mMessage;
57
58 virtual PyRouteMessageHandlerWork* clone() const;
59
60 virtual EncodeStream& encode(EncodeStream& ostr) const;
62};
63
65{
66 public:
67 PyRouteWorker(resip::PyExtensionBase& py, Py::Callable& action, Py::Callable& messageHandlerAction);
68 virtual ~PyRouteWorker();
69
70 virtual PyRouteWorker* clone() const override;
71
72 virtual void onStart() override;
73 virtual bool process(resip::ApplicationMessage* msg) override;
74
77
78 protected:
80 std::unique_ptr<resip::PyExternalUser> mPyUser;
81 Py::Callable& mAction;
82 Py::Callable& mMessageHandlerAction;
83};
84
85}
86
87
88#endif
89
90/* ====================================================================
91 *
92 * Copyright (c) 2022, Software Freedom Institute https://softwarefreedom.institute
93 * Copyright (c) 2013-2022, Daniel Pocock https://danielpocock.com
94 *
95 * Redistribution and use in source and binary forms, with or without
96 * modification, are permitted provided that the following conditions
97 * are met:
98 *
99 * 1. Redistributions of source code must retain the above copyright
100 * notice, this list of conditions and the following disclaimer.
101 *
102 * 2. Redistributions in binary form must reproduce the above copyright
103 * notice, this list of conditions and the following disclaimer in
104 * the documentation and/or other materials provided with the
105 * distribution.
106 *
107 * 3. Neither the name of the author(s) nor the names of any contributors
108 * may be used to endorse or promote products derived from this software
109 * without specific prior written permission.
110 *
111 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
112 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
113 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
114 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
115 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
116 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
117 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
118 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
119 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
120 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
121 * SUCH DAMAGE.
122 *
123 * ====================================================================
124 *
125 *
126 */
127
virtual PyRouteMessageHandlerWork * clone() const
virtual EncodeStream & encode(EncodeStream &ostr) const
output the entire message to stream
std::shared_ptr< resip::SipMessage > mMessage
virtual EncodeStream & encodeBrief(EncodeStream &ostr) const
output a brief description to stream
resip::Data mResponseMessage
resip::SipMessage & mMessage
virtual PyRouteWork * clone() const
virtual EncodeStream & encodeBrief(EncodeStream &ostr) const
output a brief description to stream
std::vector< resip::Data > mTargets
virtual EncodeStream & encode(EncodeStream &ostr) const
output the entire message to stream
virtual bool process(resip::ApplicationMessage *msg) override
bool processWork(PyRouteWork *work)
bool processMessageHandlerWork(PyRouteMessageHandlerWork *work)
resip::PyExtensionBase & mPy
std::unique_ptr< resip::PyExternalUser > mPyUser
Py::Callable & mAction
virtual PyRouteWorker * clone() const override
Py::Callable & mMessageHandlerAction
virtual void onStart() override
A base-class for messages used by applications.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Represents a SIP message.
The base-class for an RFC 3261 Transaction User.
This Class is used to implement a primitive form of RPC using loose XML formatting.
#define EncodeStream
void list()
Definition userAdmin.cxx:66