kea-custom-hooks
FeM custom hooks libraries for Kea DHCP
Public Member Functions | List of all members
aai::XmlRpcServer Class Reference

Abstraction for an XML-RPC server. More...

#include <XmlRpcServer.hpp>

Public Member Functions

 XmlRpcServer (uint16_t listen_port)
 Create an XML-RPC server which listens on all interfaces on the given port. More...
 
 XmlRpcServer (const struct sockaddr *sa, socklen_t sa_len)
 Create an XML-RPC server listening on the interfaces and ports as specified by the given sockaddr object. More...
 
 XmlRpcServer (const XmlRpcServer &)=delete
 
XmlRpcServeroperator= (const XmlRpcServer &)=delete
 
 XmlRpcServer (XmlRpcServer &&)=delete
 
XmlRpcServeroperator= (XmlRpcServer &&)=delete
 
 ~XmlRpcServer ()
 
void start ()
 Start the XML-RPC server. More...
 
void stop ()
 Stop the XML-RPC server. More...
 
void register_method_handler (std::string_view name, std::function< std::optional< std::string >(const std::string &)> handler)
 Register a method handler. More...
 

Detailed Description

Abstraction for an XML-RPC server.

This class represents an abstraction for interacting with an underlying XML-RPC server library.

After initialization, the server needs to be provided with method handlers. These can be registered by specifying a name and function pointer to register_method_handler(). When an RPC call is received, the server unpacks the parameters and calls the specified method handler. The return value of the function (if defined) is then packed into the RPC result. If no return value exists, nil is returned.

Exceptions occuring during execution of a method handler result in the RPC result indicating an error.

Definition at line 30 of file XmlRpcServer.hpp.

Constructor & Destructor Documentation

◆ XmlRpcServer() [1/4]

aai::XmlRpcServer::XmlRpcServer ( uint16_t  listen_port)
explicit

Create an XML-RPC server which listens on all interfaces on the given port.

Definition at line 86 of file XmlRpcServer.cpp.

◆ XmlRpcServer() [2/4]

aai::XmlRpcServer::XmlRpcServer ( const struct sockaddr *  sa,
socklen_t  sa_len 
)

Create an XML-RPC server listening on the interfaces and ports as specified by the given sockaddr object.

Definition at line 90 of file XmlRpcServer.cpp.

◆ XmlRpcServer() [3/4]

aai::XmlRpcServer::XmlRpcServer ( const XmlRpcServer )
delete

◆ XmlRpcServer() [4/4]

aai::XmlRpcServer::XmlRpcServer ( XmlRpcServer &&  )
delete

◆ ~XmlRpcServer()

aai::XmlRpcServer::~XmlRpcServer ( )

Definition at line 94 of file XmlRpcServer.cpp.

Member Function Documentation

◆ operator=() [1/2]

XmlRpcServer & aai::XmlRpcServer::operator= ( const XmlRpcServer )
delete

◆ operator=() [2/2]

XmlRpcServer & aai::XmlRpcServer::operator= ( XmlRpcServer &&  )
delete

◆ register_method_handler()

void aai::XmlRpcServer::register_method_handler ( std::string_view  name,
std::function< std::optional< std::string >(const std::string &)>  handler 
)

Register a method handler.

This function registers the specified function as handler for the method with the given name. This function template does not support arbitrary handler method signatures. Compiler errors may indicate that a certain handler method signature is not supported.

Definition at line 120 of file XmlRpcServer.cpp.

◆ start()

void aai::XmlRpcServer::start ( )

Start the XML-RPC server.

This function starts the XML-RPC server in a separate thread. It can be terminated by calling stop().

Definition at line 100 of file XmlRpcServer.cpp.

◆ stop()

void aai::XmlRpcServer::stop ( )

Stop the XML-RPC server.

Definition at line 111 of file XmlRpcServer.cpp.


The documentation for this class was generated from the following files: