BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
XmlRpcServerConnection.h
Go to the documentation of this file.
1#ifndef _XMLRPCSERVERCONNECTION_H_
2#define _XMLRPCSERVERCONNECTION_H_
3//
4// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
5//
6#if defined(_MSC_VER)
7# pragma warning(disable:4786) // identifier was truncated in debug info
8#endif
9
10#ifndef MAKEDEPEND
11# include <string>
12#endif
13
14#include "XmlRpcValue.h"
15#include "XmlRpcSource.h"
16
17namespace XmlRpc {
18
19
20 // The server waits for client connections and provides methods
21 class XmlRpcServer;
22 class XmlRpcServerMethod;
23
24 //! A class to handle XML RPC requests from a particular client
26 public:
27 // Static data
28 static const char METHODNAME_TAG[];
29 static const char PARAMS_TAG[];
30 static const char PARAMS_ETAG[];
31 static const char PARAM_TAG[];
32 static const char PARAM_ETAG[];
33
34 static const std::string SYSTEM_MULTICALL;
35 static const std::string METHODNAME;
36 static const std::string PARAMS;
37
38 static const std::string FAULTCODE;
39 static const std::string FAULTSTRING;
40
41 //! Constructor
42 XmlRpcServerConnection(int fd, XmlRpcServer* server, bool deleteOnClose = false);
43 //! Destructor
45
46 // XmlRpcSource interface implementation
47 //! Handle IO on the client connection socket.
48 //! @param eventType Type of IO event that occurred. @see XmlRpcDispatch::EventType.
49 virtual unsigned handleEvent(unsigned eventType);
50
51 protected:
52
53 bool readHeader();
54 bool readRequest();
55 bool writeResponse();
56
57 // Parses the request, runs the method, generates the response xml.
58 virtual void executeRequest();
59
60 // Parse the methodName and parameters from the request.
61 std::string parseRequest(XmlRpcValue& params);
62
63 // Execute a named method with the specified params.
64 bool executeMethod(const std::string& methodName, XmlRpcValue& params, XmlRpcValue& result);
65
66 // Execute multiple calls and return the results in an array.
67 bool executeMulticall(const std::string& methodName, XmlRpcValue& params, XmlRpcValue& result);
68
69 // Construct a response from the result XML.
70 void generateResponse(std::string const& resultXml);
71 void generateFaultResponse(std::string const& msg, int errorCode = -1);
72 std::string generateHeader(std::string const& body);
73
74
75 // The XmlRpc server that accepted this connection
77
78 // Possible IO states for the connection
81
82 // Request headers
83 std::string _header;
84
85 // Number of bytes expected in the request body (parsed from header)
87
88 // Request body
89 std::string _request;
90
91 // Response
92 std::string _response;
93
94 // Number of bytes of the response written so far
96
97 // Whether to keep the current client connection open for further requests
99 };
100} // namespace XmlRpc
101
102#endif // _XMLRPCSERVERCONNECTION_H_
A class to handle XML RPC requests from a particular client.
bool executeMethod(const std::string &methodName, XmlRpcValue &params, XmlRpcValue &result)
std::string parseRequest(XmlRpcValue &params)
void generateFaultResponse(std::string const &msg, int errorCode=-1)
void generateResponse(std::string const &resultXml)
static const std::string METHODNAME
std::string generateHeader(std::string const &body)
static const std::string FAULTSTRING
XmlRpcServerConnection(int fd, XmlRpcServer *server, bool deleteOnClose=false)
Constructor.
bool executeMulticall(const std::string &methodName, XmlRpcValue &params, XmlRpcValue &result)
virtual unsigned handleEvent(unsigned eventType)
static const std::string SYSTEM_MULTICALL
A class to handle XML RPC requests.
An RPC source represents a file descriptor to monitor.
RPC method arguments and results are represented by Values.
Definition XmlRpcValue.h:22