reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
XmlRpcConnection.hxx
Go to the documentation of this file.
1#if !defined(XmlRpcConnection_hxx)
2#define XmlRpcConnection_hxx
3
4#include <atomic>
5#include <map>
6#include <rutil/Data.hxx>
7#include <rutil/Socket.hxx>
10
12
13namespace repro
14{
15
17{
18public:
20 virtual ~XmlRpcConnectionBase();
21
22 unsigned int getConnectionId() const { return mConnectionId; }
23 unsigned int getNextRequestId() { return mNextRequestId++; }
24
25 virtual void buildFdSet(resip::FdSet& fdset) = 0;
26 virtual bool process(resip::FdSet& fdset) = 0;
27
28 virtual bool sendResponse(unsigned int requestId, const resip::Data& responseData, bool isFinal);
29 virtual void sendEvent(const resip::Data& eventData) = 0;
30
31protected:
32 virtual void sendResponse(const resip::Data& response) = 0;
33
35
36 typedef std::map<unsigned int, resip::Data> RequestMap;
38
39private:
40 const unsigned int mConnectionId;
41 static std::atomic<unsigned int> NextConnectionId;
42 unsigned int mNextRequestId;
43};
44
46{
47 friend class XmlRpcServerBase;
48
49public:
52
53 virtual void buildFdSet(resip::FdSet& fdset);
54 virtual bool process(resip::FdSet& fdset);
55
56 virtual void sendEvent(const resip::Data& eventData);
57
58protected:
59 virtual void sendResponse(const resip::Data& response);
60
61private:
62 bool processSomeReads();
63 bool processSomeWrites();
64 bool tryParse(); // returns true if we processed something and there is more data in the buffer
65
66 resip::Socket mSock;
67 resip::Data mRxBuffer;
68 resip::Data mTxBuffer;
69};
70
71#ifdef BUILD_QPID_PROTON
72
74{
75 friend class XmlRpcServerBase;
76
77public:
79 std::shared_ptr<resip::ProtonThreadBase::ProtonSenderBase> sender);
81
82 void onRequest(unsigned int requestId, const resip::Data& request);
83
84 virtual void buildFdSet(resip::FdSet& fdset);
85 virtual bool process(resip::FdSet& fdset);
86
87 virtual void sendEvent(const resip::Data& eventData);
88
89protected:
90 virtual void sendResponse(const resip::Data& response);
91
92private:
94 std::shared_ptr<resip::ProtonThreadBase::ProtonSenderBase> mSender;
95};
96
97#endif
98
99}
100
101#endif
102
103/* ====================================================================
104 * The Vovida Software License, Version 1.0
105 *
106 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
107 * Copyright (c) 2010 SIP Spectrum, Inc. All rights reserved.
108 * Copyright (c) 2022 Daniel Pocock https://danielpocock.com
109 * Copyright (c) 2022 Software Freedom Institute LLC https://softwarefreedom.institute
110 *
111 * Redistribution and use in source and binary forms, with or without
112 * modification, are permitted provided that the following conditions
113 * are met:
114 *
115 * 1. Redistributions of source code must retain the above copyright
116 * notice, this list of conditions and the following disclaimer.
117 *
118 * 2. Redistributions in binary form must reproduce the above copyright
119 * notice, this list of conditions and the following disclaimer in
120 * the documentation and/or other materials provided with the
121 * distribution.
122 *
123 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
124 * and "Vovida Open Communication Application Library (VOCAL)" must
125 * not be used to endorse or promote products derived from this
126 * software without prior written permission. For written
127 * permission, please contact vocal@vovida.org.
128 *
129 * 4. Products derived from this software may not be called "VOCAL", nor
130 * may "VOCAL" appear in their name, without prior written
131 * permission of Vovida Networks, Inc.
132 *
133 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
134 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
135 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
136 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
137 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
138 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
139 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
140 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
141 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
142 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
144 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
145 * DAMAGE.
146 *
147 * ====================================================================
148 *
149 * This software consists of voluntary contributions made by Vovida
150 * Networks, Inc. and many individuals on behalf of Vovida Networks,
151 * Inc. For more information on Vovida Networks, Inc., please see
152 * <http://www.vovida.org/>.
153 *
154 */
Handles cross-platform sockets compatibility.
virtual bool sendResponse(unsigned int requestId, const resip::Data &responseData, bool isFinal)
virtual void sendResponse(const resip::Data &response)=0
std::map< unsigned int, resip::Data > RequestMap
virtual bool process(resip::FdSet &fdset)=0
virtual void sendEvent(const resip::Data &eventData)=0
virtual void buildFdSet(resip::FdSet &fdset)=0
unsigned int getConnectionId() const
virtual void sendResponse(const resip::Data &response)
virtual bool process(resip::FdSet &fdset)
virtual void buildFdSet(resip::FdSet &fdset)
virtual void sendEvent(const resip::Data &eventData)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Object-oriented wrapper for your platform's file-descriptor set.
Definition Socket.hxx:162
This Class is used to implement a primitive form of RPC using loose XML formatting.
int Socket
Definition Socket.hxx:94
void list()
Definition userAdmin.cxx:66