BOSS 8.0.0
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 "XmlRpcSource.h"
15#include "XmlRpcValue.h"
16
17namespace XmlRpc {
18
19 // The server waits for client connections and provides methods
20 class XmlRpcServer;
22
23 //! A class to handle XML RPC requests from a particular client
25 public:
26 // Static data
27 static const char METHODNAME_TAG[];
28 static const char PARAMS_TAG[];
29 static const char PARAMS_ETAG[];
30 static const char PARAM_TAG[];
31 static const char PARAM_ETAG[];
32
33 static const std::string SYSTEM_MULTICALL;
34 static const std::string METHODNAME;
35 static const std::string PARAMS;
36
37 static const std::string FAULTCODE;
38 static const std::string FAULTSTRING;
39
40 //! Constructor
41 XmlRpcServerConnection( int fd, XmlRpcServer* server, bool deleteOnClose = false );
42 //! Destructor
44
45 // XmlRpcSource interface implementation
46 //! Handle IO on the client connection socket.
47 //! @param eventType Type of IO event that occurred. @see XmlRpcDispatch::EventType.
48 virtual unsigned handleEvent( unsigned eventType );
49
50 protected:
51 bool readHeader();
52 bool readRequest();
53 bool writeResponse();
54
55 // Parses the request, runs the method, generates the response xml.
56 virtual void executeRequest();
57
58 // Parse the methodName and parameters from the request.
59 std::string parseRequest( XmlRpcValue& params );
60
61 // Execute a named method with the specified params.
62 bool executeMethod( const std::string& methodName, XmlRpcValue& params,
63 XmlRpcValue& result );
64
65 // Execute multiple calls and return the results in an array.
66 bool executeMulticall( const std::string& methodName, XmlRpcValue& params,
67 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 // The XmlRpc server that accepted this connection
76
77 // Possible IO states for the connection
80
81 // Request headers
82 std::string _header;
83
84 // Number of bytes expected in the request body (parsed from header)
86
87 // Request body
88 std::string _request;
89
90 // Response
91 std::string _response;
92
93 // Number of bytes of the response written so far
95
96 // Whether to keep the current client connection open for further requests
98 };
99} // namespace XmlRpc
100
101#endif // _XMLRPCSERVERCONNECTION_H_
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
Abstract class representing a single RPC method.
A class to handle XML RPC requests.
XmlRpcSource(int fd=-1, bool deleteOnClose=false)
RPC method arguments and results are represented by Values.
Definition XmlRpcValue.h:22