From 922cb5559b9f2f97279fa24cc9c5862c8b666495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 8 Mar 2005 10:23:43 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r2603, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/iem/iemxmlrpc/; revision=2604 --- xmlrpc++/src/XmlRpcServer.h | 104 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 xmlrpc++/src/XmlRpcServer.h (limited to 'xmlrpc++/src/XmlRpcServer.h') diff --git a/xmlrpc++/src/XmlRpcServer.h b/xmlrpc++/src/XmlRpcServer.h new file mode 100644 index 0000000..8172733 --- /dev/null +++ b/xmlrpc++/src/XmlRpcServer.h @@ -0,0 +1,104 @@ + +#ifndef _XMLRPCSERVER_H_ +#define _XMLRPCSERVER_H_ +// +// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley +// +#if defined(_MSC_VER) +# pragma warning(disable:4786) // identifier was truncated in debug info +#endif + +#ifndef MAKEDEPEND +# include +# include +#endif + +#include "XmlRpcDispatch.h" +#include "XmlRpcSource.h" + +namespace XmlRpc { + + + // An abstract class supporting XML RPC methods + class XmlRpcServerMethod; + + // Class representing connections to specific clients + class XmlRpcServerConnection; + + // Class representing argument and result values + class XmlRpcValue; + + + //! A class to handle XML RPC requests + class XmlRpcServer : public XmlRpcSource { + public: + //! Create a server object. + XmlRpcServer(); + //! Destructor. + virtual ~XmlRpcServer(); + + //! Specify whether introspection is enabled or not. Default is not enabled. + void enableIntrospection(bool enabled=true); + + //! Add a command to the RPC server + void addMethod(XmlRpcServerMethod* method); + + //! Remove a command from the RPC server + void removeMethod(XmlRpcServerMethod* method); + + //! Remove a command from the RPC server by name + void removeMethod(const std::string& methodName); + + //! Look up a method by name + XmlRpcServerMethod* findMethod(const std::string& name) const; + + //! Create a socket, bind to the specified port, and + //! set it in listen mode to make it available for clients. + bool bindAndListen(int port, int backlog = 5); + + //! Process client requests for the specified time + void work(double msTime); + + //! Temporarily stop processing client requests and exit the work() method. + void exit(); + + //! Close all connections with clients and the socket file descriptor + void shutdown(); + + //! Introspection support + void listMethods(XmlRpcValue& result); + + // XmlRpcSource interface implementation + + //! Handle client connection requests + virtual unsigned handleEvent(unsigned eventType); + + //! Remove a connection from the dispatcher + virtual void removeConnection(XmlRpcServerConnection*); + + protected: + + //! Accept a client connection request + virtual void acceptConnection(); + + //! Create a new connection object for processing requests from a specific client. + virtual XmlRpcServerConnection* createConnection(int socket); + + // Whether the introspection API is supported by this server + bool _introspectionEnabled; + + // Event dispatcher + XmlRpcDispatch _disp; + + // Collection of methods. This could be a set keyed on method name if we wanted... + typedef std::map< std::string, XmlRpcServerMethod* > MethodMap; + MethodMap _methods; + + // system methods + XmlRpcServerMethod* _listMethods; + XmlRpcServerMethod* _methodHelp; + + }; +} // namespace XmlRpc + +#endif //_XMLRPCSERVER_H_ -- cgit v1.2.1