reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
XmlRpcServerBase.hxx
Go to the documentation of this file.
1#if !defined(XmlRpcServerBase_hxx)
2#define XmlRpcServerBase_hxx
3
4#include <map>
5#include <memory>
6#include <rutil/Data.hxx>
7#include <rutil/Socket.hxx>
9#include <rutil/Fifo.hxx>
10#include <resip/stack/Tuple.hxx>
12#include <rutil/ThreadIf.hxx>
13
14#ifdef BUILD_QPID_PROTON
16#include <proton/message.hpp>
17#endif
18
19#include <memory>
20
24
25namespace repro
26{
27class XmlRpcConnectionBase;
28
30{
31public:
33 unsigned int requestId,
35 bool isFinal) :
36 mConnectionId(connectionId),
37 mRequestId(requestId),
38 mResponseData(responseData),
39 mIsFinal(isFinal) {}
40
41 unsigned int getConnectionId() const noexcept { return mConnectionId; }
42 unsigned int getRequestId() const noexcept { return mRequestId; }
43 const resip::Data& getResponseData() const noexcept { return mResponseData; }
44 bool getIsFinal() const noexcept { return mIsFinal; }
45
46private:
47 unsigned int mConnectionId;
48 unsigned int mRequestId;
49 resip::Data mResponseData;
50 bool mIsFinal;
51};
52
53class XmlRpcServerBase;
54
56{
57public:
58 XmlRpcHandler(std::shared_ptr<XmlRpcServerBase> rpc) : mRpc(rpc) {};
59 virtual ~XmlRpcHandler();
60 virtual void handleRequest(unsigned int connectionId,
61 unsigned int requestId,
62 const resip::Data& request) = 0;
63 virtual void buildFdSet(resip::FdSet& fdset);
65 bool isSane();
66protected:
67 std::shared_ptr<XmlRpcServerBase> mRpc;
68};
69
71{
73
74protected:
77 void setSane(bool sane) { mSane = sane; };
78
79public:
80 virtual ~XmlRpcServerBase();
81
82 virtual void buildFdSet(resip::FdSet& fdset);
84
85 bool isSane();
86
87 // thread safe - uses fifo
88 virtual void sendResponse(unsigned int connectionId,
89 unsigned int requestId,
91 bool isFinal=true);
92
93 // thread safe - uses fifo (use connectionId == 0 to send to all connections)
94 virtual void sendEvent(unsigned int connectionId,
95 const resip::Data& eventData);
96
97 virtual void handleRequest(unsigned int connectionId,
98 unsigned int requestId,
100
102 bool mSane;
103 typedef std::map<unsigned int, XmlRpcConnectionBase*> ConnectionMap;
107};
108
110{
112
113public:
115 virtual ~XmlRpcSocketServer();
116
117 virtual void buildFdSet(resip::FdSet& fdset);
118
119 static void logSocketError(int e);
120
121protected:
123
124private:
125 static const unsigned int MaxConnections = 60; // Note: use caution if making this any bigger, default fd_set size in windows is 64
126
127 resip::Socket mFd;
128 resip::Tuple mTuple;
129
130 void closeOldestConnection();
131};
132
133#ifdef BUILD_QPID_PROTON
136 public std::enable_shared_from_this<XmlRpcProtonServer>
137{
138 friend class XmlRpcProtonConnection;
139
140public:
142 virtual ~XmlRpcProtonServer();
143
144 virtual void buildFdSet(resip::FdSet& fdset) override;
145 //void process(resip::FdSet& fdset);
146
147protected:
148 virtual void processIncoming(resip::FdSet& fdset) override;
149
150private:
152 bool mBroadcast;
153 bool mReady;
154 std::shared_ptr<resip::ProtonThreadBase> mQpidProtonThread;
155 std::shared_ptr<resip::ProtonThreadBase::ProtonSenderBase> mProtonSender;
156
157 unsigned int mConnectionId = 0;
158 unsigned int mNextRequestId = 0;
159 std::map<resip::Data, unsigned int> mQueueConnection;
160};
161#endif
162
163}
164
165#endif
166
167/* ====================================================================
168 * The Vovida Software License, Version 1.0
169 *
170 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
171 * Copyright (c) 2010 SIP Spectrum, Inc. All rights reserved.
172 * Copyright (c) 2022 Daniel Pocock https://danielpocock.com
173 * Copyright (c) 2022 Software Freedom Institute LLC https://softwarefreedom.institute
174 *
175 * Redistribution and use in source and binary forms, with or without
176 * modification, are permitted provided that the following conditions
177 * are met:
178 *
179 * 1. Redistributions of source code must retain the above copyright
180 * notice, this list of conditions and the following disclaimer.
181 *
182 * 2. Redistributions in binary form must reproduce the above copyright
183 * notice, this list of conditions and the following disclaimer in
184 * the documentation and/or other materials provided with the
185 * distribution.
186 *
187 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
188 * and "Vovida Open Communication Application Library (VOCAL)" must
189 * not be used to endorse or promote products derived from this
190 * software without prior written permission. For written
191 * permission, please contact vocal@vovida.org.
192 *
193 * 4. Products derived from this software may not be called "VOCAL", nor
194 * may "VOCAL" appear in their name, without prior written
195 * permission of Vovida Networks, Inc.
196 *
197 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
198 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
199 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
200 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
201 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
202 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
203 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
204 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
205 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
206 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
207 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
208 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
209 * DAMAGE.
210 *
211 * ====================================================================
212 *
213 * This software consists of voluntary contributions made by Vovida
214 * Networks, Inc. and many individuals on behalf of Vovida Networks,
215 * Inc. For more information on Vovida Networks, Inc., please see
216 * <http://www.vovida.org/>.
217 *
218 */
219
Handles cross-platform sockets compatibility.
bool getIsFinal() const noexcept
ResponseInfo(unsigned int connectionId, unsigned int requestId, const resip::Data &responseData, bool isFinal)
unsigned int getConnectionId() const noexcept
unsigned int getRequestId() const noexcept
const resip::Data & getResponseData() const noexcept
XmlRpcHandler(std::shared_ptr< XmlRpcServerBase > rpc)
virtual void buildFdSet(resip::FdSet &fdset)
void process(resip::FdSet &fdset)
std::shared_ptr< XmlRpcServerBase > mRpc
virtual void handleRequest(unsigned int connectionId, unsigned int requestId, const resip::Data &request)=0
void process(resip::FdSet &fdset)
resip::SelectInterruptor mSelectInterruptor
virtual void buildFdSet(resip::FdSet &fdset)
virtual void handleRequest(unsigned int connectionId, unsigned int requestId, const resip::Data &request)
virtual void sendEvent(unsigned int connectionId, const resip::Data &eventData)
resip::Fifo< ResponseInfo > mResponseFifo
virtual void sendResponse(unsigned int connectionId, unsigned int requestId, const resip::Data &responseData, bool isFinal=true)
std::map< unsigned int, XmlRpcConnectionBase * > ConnectionMap
virtual void processIncoming(resip::FdSet &fdset)=0
static void logSocketError(int e)
virtual void buildFdSet(resip::FdSet &fdset)
void processIncoming(resip::FdSet &fdset)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
Object-oriented wrapper for your platform's file-descriptor set.
Definition Socket.hxx:162
A templated, threadsafe message-queue class.
Definition Fifo.hxx:16
Used to 'artificially' interrupt a select call.
Represents a network address.
Definition Tuple.hxx:59
This Class is used to implement a primitive form of RPC using loose XML formatting.
int Socket
Definition Socket.hxx:94
IpVersion
An enumeration of IP versions.
void list()
Definition userAdmin.cxx:66