54 MethodMap::iterator i =
_methods.find(methodName);
64 MethodMap::const_iterator i =
_methods.find(name);
119 XmlRpcUtil::log(2,
"XmlRpcServer::bindAndListen: server listening on port %d fd %d",
_port, fd);
167 XmlRpcUtil::log(2,
"XmlRpcServer::acceptConnection: creating a connection");
207 static const std::string
LIST_METHODS(
"system.listMethods");
208 static const std::string
METHOD_HELP(
"system.methodHelp");
209 static const std::string
MULTICALL(
"system.multicall");
220 _server->listMethods(result);
223 std::string
help() {
return std::string(
"List all methods available on a server as an array of strings"); }
245 std::string
help() {
return std::string(
"Retrieve the help string for a named method"); }
283 result[i++] = it->first;
A class to handle XML RPC requests from a particular client.
virtual XmlRpcServerConnection * createConnection(int socket)
Create a new connection object for processing requests from a specific client.
virtual void acceptConnection()
Accept a client connection request.
static bool setReuseAddr(int socket)
RPC method arguments and results are represented by Values.
static const std::string METHOD_HELP("system.methodHelp")
static int get_port(int socket)
void execute(XmlRpcValue &, XmlRpcValue &result)
Execute the method. Subclasses must provide a definition for this method.
static int accept(int socket)
Accept a client connection request.
void shutdown()
Close all connections with clients and the socket file descriptor.
void work(double msTime)
Process client requests for the specified time.
bool bindAndListen(int port, int backlog=5)
XmlRpcServer()
Create a server object.
void addMethod(XmlRpcServerMethod *method)
Add a command to the RPC server.
XmlRpcServerMethod * findMethod(const std::string &name) const
Look up a method by name.
void removeMethod(XmlRpcServerMethod *method)
Remove a command from the RPC server.
void removeSource(XmlRpcSource *source)
static void error(const char *fmt,...)
Dump error messages somewhere.
virtual unsigned handleEvent(unsigned eventType)
Handle client connection requests.
void clear()
Clear all sources from the monitored sources list. Sources are closed.
virtual ~XmlRpcServer()
Destructor.
static std::string getErrorMsg()
Returns message corresponding to last error.
int getfd() const
Return the file descriptor being monitored.
Abstract class representing a single RPC method.
XmlRpcServerMethod * _listMethods
virtual void close()
Close the owned fd. If deleteOnClose was specified at construction, the object is deleted...
void setfd(int fd)
Specify the file descriptor to monitor.
static bool bind(int socket, int port)
Bind to a specified port.
virtual void removeConnection(XmlRpcServerConnection *)
Remove a connection from the dispatcher.
void setSize(int size)
Specify the size for array values. Array values will grow beyond this size if needed.
static const std::string MULTICALL("system.multicall")
void execute(XmlRpcValue ¶ms, XmlRpcValue &result)
Execute the method. Subclasses must provide a definition for this method.
void enableIntrospection(bool enabled=true)
Specify whether introspection is enabled or not. Default is not enabled.
A class to handle XML RPC requests.
static bool listen(int socket, int backlog)
Set socket in listen mode.
static int socket()
Creates a stream (TCP) socket. Returns -1 on failure.
static void close(int socket)
Closes a socket.
XmlRpcServerMethod * _methodHelp
void addSource(XmlRpcSource *source, unsigned eventMask)
virtual std::string help()
static const std::string LIST_METHODS("system.listMethods")
void exit()
Exit from work routine.
static bool setNonBlocking(int socket)
Sets a stream (TCP) socket to perform non-blocking IO. Returns false on failure.
ListMethods(XmlRpcServer *s)
void exit()
Temporarily stop processing client requests and exit the work() method.
void listMethods(XmlRpcValue &result)
Introspection support.
MethodHelp(XmlRpcServer *s)
bool _introspectionEnabled
static void log(int level, const char *fmt,...)
Dump messages somewhere.
std::string & name()
Returns the name of the method.