XmlRpcServerConnection.h
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 #ifndef _XMLRPCSERVERCONNECTION_H_
3 #define _XMLRPCSERVERCONNECTION_H_
4 //
5 // XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
6 //
7 #if defined(_MSC_VER)
8 # pragma warning(disable:4786) // identifier was truncated in debug info
9 #endif
10 
11 #ifndef MAKEDEPEND
12 # include <string>
13 #endif
14 
15 #include "xmlrpcpp/XmlRpcValue.h"
16 #include "xmlrpcpp/XmlRpcSource.h"
17 #include "xmlrpcpp/XmlRpcDecl.h"
18 
19 namespace XmlRpc {
20 
21 
22  // The server waits for client connections and provides methods
23  class XmlRpcServer;
24  class XmlRpcServerMethod;
25 
27  class XMLRPCPP_DECL XmlRpcServerConnection : public XmlRpcSource {
28  public:
29  // Static data
30  static const char METHODNAME_TAG[];
31  static const char PARAMS_TAG[];
32  static const char PARAMS_ETAG[];
33  static const char PARAM_TAG[];
34  static const char PARAM_ETAG[];
35 
36  static const std::string SYSTEM_MULTICALL;
37  static const std::string METHODNAME;
38  static const std::string PARAMS;
39 
40  static const std::string FAULTCODE;
41  static const std::string FAULTSTRING;
42 
44  XmlRpcServerConnection(int fd, XmlRpcServer* server, bool deleteOnClose = false);
46  virtual ~XmlRpcServerConnection();
47 
48  // XmlRpcSource interface implementation
51  virtual unsigned handleEvent(unsigned eventType);
52 
53  protected:
54 
55  bool readHeader();
56  bool readRequest();
57  bool writeResponse();
58 
59  // Parses the request, runs the method, generates the response xml.
60  virtual void executeRequest();
61 
62  // Parse the methodName and parameters from the request.
63  std::string parseRequest(XmlRpcValue& params);
64 
65  // Execute a named method with the specified params.
66  bool executeMethod(const std::string& methodName, XmlRpcValue& params, XmlRpcValue& result);
67 
68  // Execute multiple calls and return the results in an array.
69  bool executeMulticall(const std::string& methodName, XmlRpcValue& params, XmlRpcValue& result);
70 
71  // Construct a response from the result XML.
72  void generateResponse(std::string const& resultXml);
73  void generateFaultResponse(std::string const& msg, int errorCode = -1);
74  std::string generateHeader(std::string const& body);
75 
76 
77  // The XmlRpc server that accepted this connection
78  XmlRpcServer* _server;
79 
80  // Possible IO states for the connection
81  enum ServerConnectionState { READ_HEADER, READ_REQUEST, WRITE_RESPONSE };
82  ServerConnectionState _connectionState;
83 
84  // Request headers
85  std::string _header;
86 
87  // Number of bytes expected in the request body (parsed from header)
88  int _contentLength;
89 
90  // Request body
91  std::string _request;
92 
93  // Response
94  std::string _response;
95 
96  // Number of bytes of the response written so far
97  int _bytesWritten;
98 
99  // Whether to keep the current client connection open for further requests
100  bool _keepAlive;
101  };
102 } // namespace XmlRpc
103 
104 #endif // _XMLRPCSERVERCONNECTION_H_
msg
msg
XmlRpc
parseRequest
std::string parseRequest(std::string const &xml, XmlRpcValue &params)
sick_scan_base.h
XMLRPCPP_DECL
#define XMLRPCPP_DECL
Definition: XmlRpcDecl.h:53
test_server.server
server
Definition: test_server.py:219


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:13