|
OverSim
|
A class to handle XML RPC requests. More...
#include <XmlRpcServer.h>
Public Member Functions | |
| XmlRpcServer () | |
| Create a server object. | |
| virtual | ~XmlRpcServer () |
| Destructor. | |
| void | enableIntrospection (bool enabled=true) |
| Specify whether introspection is enabled or not. Default is not enabled. | |
| void | addMethod (XmlRpcServerMethod *method) |
| Add a command to the RPC server. | |
| void | removeMethod (XmlRpcServerMethod *method) |
| Remove a command from the RPC server. | |
| void | removeMethod (const std::string &methodName) |
| Remove a command from the RPC server by name. | |
| XmlRpcServerMethod * | findMethod (const std::string &name) const |
| Look up a method by name. | |
| bool | bindAndListen (int port, int backlog=5) |
| Create a socket, bind to the specified port, and set it in listen mode to make it available for clients. | |
| int | getPort (void) const |
| Get the port number this server is listening on. | |
| void | work (double msTime) |
| Process client requests for the specified time. | |
| void | exit () |
| Temporarily stop processing client requests and exit the work() method. | |
| void | shutdown () |
| Close all connections with clients and the socket file descriptor. | |
| void | listMethods (XmlRpcValue &result) |
| Introspection support. | |
| virtual std::string | executeRequest (std::string const &request) |
| Parses the request xml, runs the method, generates the response (header+xml). | |
| virtual unsigned | handleEvent (unsigned eventType) |
| Handle client connection requests. | |
| virtual void | removeConnection (XmlRpcServerConnection *) |
| Remove a connection from the dispatcher. | |
Public Member Functions inherited from XmlRpc::XmlRpcSource | |
| XmlRpcSource (int fd=-1, bool deleteOnClose=false) | |
| Constructor. | |
| virtual | ~XmlRpcSource () |
| Destructor. | |
| int | getfd () const |
| Return the file descriptor being monitored. | |
| void | setfd (int fd) |
| Specify the file descriptor to monitor. | |
| bool | getKeepOpen () const |
| Return whether the file descriptor should be kept open if it is no longer monitored. | |
| void | setKeepOpen (bool b=true) |
| Specify whether the file descriptor should be kept open if it is no longer monitored. | |
| virtual void | close () |
| Close the owned fd. If deleteOnClose was specified at construction, the object is deleted. | |
Protected Types | |
| typedef std::map< std::string, XmlRpcServerMethod * > | MethodMap |
| Collection of methods. This could be a set keyed on method name if we wanted... | |
Protected Member Functions | |
| virtual void | acceptConnection () |
| Accept a client connection request. | |
| virtual XmlRpcServerConnection * | createConnection (int socket) |
| Create a new connection object for processing requests from a specific client. | |
| virtual void | dispatchConnection (XmlRpcServerConnection *sc) |
| Hand off a new connection object to a dispatcher. | |
| std::string | parseRequest (std::string const &request, XmlRpcValue ¶ms) |
| Parse the methodName and parameters from the request. | |
| bool | executeMethod (const std::string &methodName, XmlRpcValue ¶ms, XmlRpcValue &result) |
| Execute a named method with the specified params. | |
| bool | executeMulticall (const std::string &methodName, XmlRpcValue ¶ms, XmlRpcValue &result) |
| Execute multiple calls and return the results in an array. | |
| std::string | generateResponse (std::string const &resultXml) |
| Construct a response from the result XML. | |
| std::string | generateFaultResponse (std::string const &msg, int errorCode=-1) |
| Construct a fault response. | |
| std::string | generateHeader (std::string const &body) |
| Return the appropriate headers for the response. | |
Protected Attributes | |
| bool | _introspectionEnabled |
| Whether the introspection API is supported by this server. | |
| XmlRpcDispatch | _disp |
| Event dispatcher. | |
| MethodMap | _methods |
| Registered RPC methods. | |
| XmlRpcServerMethod * | _listMethods |
| List all registered RPC methods (only available if introspection is enabled) | |
| XmlRpcServerMethod * | _methodHelp |
| Return help string for a specified method (only available if introspection is enabled) | |
Static Protected Attributes | |
| static const char | METHODNAME_TAG [] = "<methodName>" |
| static const char | PARAMS_TAG [] = "<params>" |
| static const char | PARAMS_ETAG [] = "</params>" |
| static const char | PARAM_TAG [] = "<param>" |
| static const char | PARAM_ETAG [] = "</param>" |
| static const std::string | SYSTEM_MULTICALL |
| static const std::string | METHODNAME = "methodName" |
| static const std::string | PARAMS = "params" |
| static const std::string | FAULTCODE = "faultCode" |
| static const std::string | FAULTSTRING = "faultString" |
Additional Inherited Members | |
Public Attributes inherited from XmlRpc::XmlRpcSource | |
| bool | _ssl |
| SSL_CTX * | _ssl_ctx |
| SSL * | _ssl_ssl |
| SSL_METHOD * | _ssl_meth |
A class to handle XML RPC requests.
Definition at line 40 of file XmlRpcServer.h.
|
protected |
Collection of methods. This could be a set keyed on method name if we wanted...
Definition at line 154 of file XmlRpcServer.h.
| XmlRpcServer::XmlRpcServer | ( | ) |
Create a server object.
Definition at line 34 of file XmlRpcServer.cc.
|
virtual |
Destructor.
Definition at line 42 of file XmlRpcServer.cc.
|
protectedvirtual |
Accept a client connection request.
Definition at line 175 of file XmlRpcServer.cc.
Referenced by handleEvent().
| void XmlRpcServer::addMethod | ( | XmlRpcServerMethod * | method | ) |
Add a command to the RPC server.
Definition at line 53 of file XmlRpcServer.cc.
Referenced by enableIntrospection(), and XmlRpc::XmlRpcServerMethod::XmlRpcServerMethod().
| bool XmlRpcServer::bindAndListen | ( | int | port, |
| int | backlog = 5 |
||
| ) |
Create a socket, bind to the specified port, and set it in listen mode to make it available for clients.
| port | The port to bind and listen on (zero to choose an arbitrary port) |
| backlog |
Definition at line 91 of file XmlRpcServer.cc.
|
protectedvirtual |
Create a new connection object for processing requests from a specific client.
If the client is not authorized to connect, close the socket and return 0.
Definition at line 200 of file XmlRpcServer.cc.
Referenced by acceptConnection().
|
protectedvirtual |
Hand off a new connection object to a dispatcher.
Definition at line 209 of file XmlRpcServer.cc.
Referenced by acceptConnection().
| void XmlRpcServer::enableIntrospection | ( | bool | enabled = true | ) |
Specify whether introspection is enabled or not. Default is not enabled.
Definition at line 285 of file XmlRpcServer.cc.
|
protected |
Execute a named method with the specified params.
Definition at line 376 of file XmlRpcServer.cc.
Referenced by executeMulticall(), and executeRequest().
|
protected |
Execute multiple calls and return the results in an array.
System.multicall implementation
Definition at line 395 of file XmlRpcServer.cc.
Referenced by executeRequest().
|
virtual |
Parses the request xml, runs the method, generates the response (header+xml).
Returns a fault response if an error occurs during method execution.
Definition at line 327 of file XmlRpcServer.cc.
Referenced by XmlRpc::XmlRpcServerConnection::executeRequest().
| void XmlRpcServer::exit | ( | ) |
Temporarily stop processing client requests and exit the work() method.
Definition at line 225 of file XmlRpcServer.cc.
| XmlRpcServerMethod * XmlRpcServer::findMethod | ( | const std::string & | name | ) | const |
Look up a method by name.
Definition at line 79 of file XmlRpcServer.cc.
Referenced by executeMethod().
|
protected |
Construct a fault response.
Definition at line 482 of file XmlRpcServer.cc.
Referenced by executeRequest().
|
protected |
Return the appropriate headers for the response.
Definition at line 464 of file XmlRpcServer.cc.
Referenced by generateFaultResponse(), and generateResponse().
|
protected |
Construct a response from the result XML.
Definition at line 445 of file XmlRpcServer.cc.
Referenced by executeRequest().
| int XmlRpcServer::getPort | ( | void | ) | const |
Get the port number this server is listening on.
Definition at line 145 of file XmlRpcServer.cc.
|
virtual |
Handle client connection requests.
Implements XmlRpc::XmlRpcSource.
Definition at line 165 of file XmlRpcServer.cc.
| void XmlRpcServer::listMethods | ( | XmlRpcValue & | result | ) |
Introspection support.
Definition at line 312 of file XmlRpcServer.cc.
|
protected |
Parse the methodName and parameters from the request.
Definition at line 354 of file XmlRpcServer.cc.
Referenced by executeRequest().
|
virtual |
Remove a connection from the dispatcher.
Definition at line 217 of file XmlRpcServer.cc.
Referenced by XmlRpc::XmlRpcServerConnection::~XmlRpcServerConnection().
| void XmlRpcServer::removeMethod | ( | XmlRpcServerMethod * | method | ) |
Remove a command from the RPC server.
Definition at line 60 of file XmlRpcServer.cc.
Referenced by enableIntrospection(), and XmlRpc::XmlRpcServerMethod::~XmlRpcServerMethod().
| void XmlRpcServer::removeMethod | ( | const std::string & | methodName | ) |
Remove a command from the RPC server by name.
Definition at line 69 of file XmlRpcServer.cc.
| void XmlRpcServer::shutdown | ( | ) |
Close all connections with clients and the socket file descriptor.
Definition at line 233 of file XmlRpcServer.cc.
Referenced by ~XmlRpcServer().
| void XmlRpcServer::work | ( | double | msTime | ) |
Process client requests for the specified time.
Definition at line 154 of file XmlRpcServer.cc.
|
protected |
Event dispatcher.
Definition at line 151 of file XmlRpcServer.h.
Referenced by bindAndListen(), dispatchConnection(), exit(), removeConnection(), shutdown(), and work().
|
protected |
Whether the introspection API is supported by this server.
Definition at line 148 of file XmlRpcServer.h.
Referenced by enableIntrospection(), and XmlRpcServer().
|
protected |
List all registered RPC methods (only available if introspection is enabled)
Definition at line 160 of file XmlRpcServer.h.
Referenced by enableIntrospection(), XmlRpcServer(), and ~XmlRpcServer().
|
protected |
Return help string for a specified method (only available if introspection is enabled)
Definition at line 163 of file XmlRpcServer.h.
Referenced by enableIntrospection(), XmlRpcServer(), and ~XmlRpcServer().
|
protected |
Registered RPC methods.
Definition at line 157 of file XmlRpcServer.h.
Referenced by addMethod(), findMethod(), listMethods(), removeMethod(), and ~XmlRpcServer().
|
staticprotected |
Definition at line 110 of file XmlRpcServer.h.
Referenced by executeMulticall(), and generateFaultResponse().
|
staticprotected |
Definition at line 111 of file XmlRpcServer.h.
Referenced by executeMulticall(), and generateFaultResponse().
|
staticprotected |
Definition at line 107 of file XmlRpcServer.h.
Referenced by executeMulticall().
|
staticprotected |
Definition at line 100 of file XmlRpcServer.h.
Referenced by parseRequest().
|
staticprotected |
Definition at line 104 of file XmlRpcServer.h.
Referenced by parseRequest().
|
staticprotected |
Definition at line 103 of file XmlRpcServer.h.
Referenced by parseRequest().
|
staticprotected |
Definition at line 108 of file XmlRpcServer.h.
Referenced by executeMulticall().
|
staticprotected |
Definition at line 102 of file XmlRpcServer.h.
Referenced by parseRequest().
|
staticprotected |
Definition at line 101 of file XmlRpcServer.h.
Referenced by parseRequest().
|
staticprotected |
Definition at line 106 of file XmlRpcServer.h.