reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
PyRouteProcessor.cxx
Go to the documentation of this file.
1
3#include "PyRouteWorker.hxx"
4
5#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
6
7using namespace resip;
8using namespace repro;
9
11 Processor("PyRoute"),
12 mDispatcher(dispatcher)
13{
14}
15
19
22{
23 DebugLog(<< "Monkey handling request: PyRoute");
24
25 // Has the work been done already?
26 PyRouteWork* work = dynamic_cast<PyRouteWork*>(context.getCurrentEvent());
27 if(work)
28 {
29 if(work->hasResponse())
30 {
31 resip::SipMessage response;
32 if(work->mResponseMessage.size() == 0)
33 {
34 Helper::makeResponse(response, context.getOriginalRequest(), work->mResponseCode);
35 }
36 else
37 {
39 }
40 context.sendResponse(response);
42 }
43 for(
44 std::vector<Data>::iterator i = work->mTargets.begin();
45 i != work->mTargets.end();
46 i++)
47 {
49 }
50 if(work->mTargets.size() > 0)
51 {
53 }
55 }
56
57 SipMessage& msg = context.getOriginalRequest();
58 if(msg.method() != INVITE && msg.method() != MESSAGE)
59 {
60 // We only route INVITE and MESSAGE, otherwise we ignore
62 }
63 work = new PyRouteWork(*this, context.getTransactionId(), &(context.getProxy()), msg);
64 std::unique_ptr<ApplicationMessage> app(work);
65 if(mDispatcher.post(app))
66 {
68 }
69 else
70 {
71 ErrLog(<<"mDispatcher.post failed, maybe not accepting work");
72 context.sendResponse(*std::unique_ptr<SipMessage>
73 (Helper::makeResponse(msg, 500, "Internal error")));
75 }
76}
77
78/* ====================================================================
79 *
80 * Copyright (c) 2022, Software Freedom Institute https://softwarefreedom.institute
81 * Copyright (c) 2014-2022, Daniel Pocock https://danielpocock.com
82 *
83 * Redistribution and use in source and binary forms, with or without
84 * modification, are permitted provided that the following conditions
85 * are met:
86 *
87 * 1. Redistributions of source code must retain the above copyright
88 * notice, this list of conditions and the following disclaimer.
89 *
90 * 2. Redistributions in binary form must reproduce the above copyright
91 * notice, this list of conditions and the following disclaimer in
92 * the documentation and/or other materials provided with the
93 * distribution.
94 *
95 * 3. Neither the name of the author(s) nor the names of any contributors
96 * may be used to endorse or promote products derived from this software
97 * without specific prior written permission.
98 *
99 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
100 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
101 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
102 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
103 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
104 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
105 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
106 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
107 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
108 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
109 * SUCH DAMAGE.
110 *
111 * ====================================================================
112 *
113 *
114 */
115
#define DebugLog(args_)
Definition Logger.hxx:128
#define ErrLog(args_)
Definition Logger.hxx:137
virtual processor_action_t process(RequestContext &context)
PyRouteProcessor(resip::Dispatcher &dispatcher)
resip::Data mResponseMessage
std::vector< resip::Data > mTargets
resip::SipMessage & getOriginalRequest()
Returns the SipMessage associated with the server transaction.
resip::Message * getCurrentEvent()
Returns the event that we are currently working on.
ResponseContext & getResponseContext()
void sendResponse(resip::SipMessage &response)
resip::Data getTransactionId() const
resip::Data addTarget(const resip::NameAddr &target, bool beginImmediately=false)
Adds this Target as a SimpleTarget to the collection of Targets.
size_type size() const noexcept
Returns the number of bytes in this Data.
Definition Data.hxx:599
A generic thread-bank class.
virtual bool post(std::unique_ptr< resip::ApplicationMessage > &work)
Posts a message to this thread bank.
static void makeResponse(SipMessage &response, const SipMessage &request, int responseCode, const Data &reason=Data::Empty, const Data &hostname=Data::Empty, const Data &warning=Data::Empty)
Make a response to a provided request.
Definition Helper.cxx:412
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Definition NameAddr.hxx:19
Represents a SIP message.
resip::MethodTypes method() const
returns the method type of the message
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;