1
#if !defined(XmlRpcServerBase_hxx)
2
#define XmlRpcServerBase_hxx
5
#include <rutil/Data.hxx>
6
#include <rutil/Socket.hxx>
7
#include <rutil/TransportType.hxx>
8
#include <rutil/Fifo.hxx>
9
#include <resip/stack/Tuple.hxx>
10
#include <rutil/SelectInterruptor.hxx>
14
class XmlRpcConnection;
19
ResponseInfo(unsigned int connectionId,
20
unsigned int requestId,
21
const resip::Data& responseData,
23
mConnectionId(connectionId),
24
mRequestId(requestId),
25
mResponseData(responseData),
30
unsigned int getConnectionId() const { return mConnectionId; }
31
unsigned int getRequestId() const { return mRequestId; }
32
const resip::Data& getResponseData() const { return mResponseData; }
33
bool getIsFinal() const { return mIsFinal; }
36
unsigned int mConnectionId;
37
unsigned int mRequestId;
38
resip::Data mResponseData;
42
class XmlRpcServerBase
44
friend class XmlRpcConnection;
47
XmlRpcServerBase(int port, resip::IpVersion version);
48
virtual ~XmlRpcServerBase();
50
void buildFdSet(resip::FdSet& fdset);
51
void process(resip::FdSet& fdset);
54
static void logSocketError(int e);
56
// thread safe - uses fifo
57
void sendResponse(unsigned int connectionId,
58
unsigned int requestId,
59
const resip::Data& responseData,
63
virtual void handleRequest(unsigned int connectionId,
64
unsigned int requestId,
65
const resip::Data& request) = 0;
68
static const unsigned int MaxConnections = 60; // Note: use caution if making this any bigger, default fd_set size in windows is 64
74
typedef std::map<unsigned int, XmlRpcConnection*> ConnectionMap;
75
ConnectionMap mConnections;
76
void closeOldestConnection();
78
resip::Fifo<ResponseInfo> mResponseFifo;
79
resip::SelectInterruptor mSelectInterruptor;
86
/* ====================================================================
88
Copyright (c) 2009, SIP Spectrum, Inc.
91
Redistribution and use in source and binary forms, with or without
92
modification, are permitted provided that the following conditions are
95
1. Redistributions of source code must retain the above copyright
96
notice, this list of conditions and the following disclaimer.
98
2. Redistributions in binary form must reproduce the above copyright
99
notice, this list of conditions and the following disclaimer in the
100
documentation and/or other materials provided with the distribution.
102
3. Neither the name of SIP Spectrum nor the names of its contributors
103
may be used to endorse or promote products derived from this
104
software without specific prior written permission.
106
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
107
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
108
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
109
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
110
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
111
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
112
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
113
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
114
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
116
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
118
==================================================================== */