mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
add xmlrpc-c 1.03.14 to in tree libs
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3772 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
55
libs/xmlrpc-c/examples/cpp/xmlrpc_sample_add_server.cpp
Normal file
55
libs/xmlrpc-c/examples/cpp/xmlrpc_sample_add_server.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <cassert>
|
||||
|
||||
#include <xmlrpc-c/base.hpp>
|
||||
#include <xmlrpc-c/registry.hpp>
|
||||
#include <xmlrpc-c/server_abyss.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class sampleAddMethod : public xmlrpc_c::method {
|
||||
public:
|
||||
sampleAddMethod() {
|
||||
// signature and help strings are documentation -- the client
|
||||
// can query this information with a system.methodSignature and
|
||||
// system.methodHelp RPC.
|
||||
this->_signature = "i:ii";
|
||||
// method's result and two arguments are integers
|
||||
this->_help = "This method adds two integers together";
|
||||
}
|
||||
void
|
||||
execute(xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::value * const retvalP) {
|
||||
|
||||
int const addend(paramList.getInt(0));
|
||||
int const adder(paramList.getInt(1));
|
||||
|
||||
paramList.verifyEnd(2);
|
||||
|
||||
*retvalP = xmlrpc_c::value_int(addend + adder);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
int
|
||||
main(int const,
|
||||
const char ** const) {
|
||||
|
||||
xmlrpc_c::registry myRegistry;
|
||||
|
||||
xmlrpc_c::methodPtr const sampleAddMethodP(new sampleAddMethod);
|
||||
|
||||
myRegistry.addMethod("sample.add", sampleAddMethodP);
|
||||
|
||||
xmlrpc_c::serverAbyss myAbyssServer(
|
||||
myRegistry,
|
||||
8080, // TCP port on which to listen
|
||||
"/tmp/xmlrpc_log" // Log file
|
||||
);
|
||||
|
||||
myAbyssServer.run();
|
||||
// xmlrpc_c::serverAbyss.run() never returns
|
||||
assert(false);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user