mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
merged new xmlrpc-c revision 1472 from https://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/trunk
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8545 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <xmlrpc-c/base.hpp>
|
||||
#include <xmlrpc-c/registry.hpp>
|
||||
@@ -6,6 +13,13 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef WIN32
|
||||
#define SLEEP(seconds) SleepEx(seconds * 1000);
|
||||
#else
|
||||
#define SLEEP(seconds) sleep(seconds);
|
||||
#endif
|
||||
|
||||
|
||||
class sampleAddMethod : public xmlrpc_c::method {
|
||||
public:
|
||||
sampleAddMethod() {
|
||||
@@ -26,6 +40,11 @@ public:
|
||||
paramList.verifyEnd(2);
|
||||
|
||||
*retvalP = xmlrpc_c::value_int(addend + adder);
|
||||
|
||||
// Sometimes, make it look hard (so client can see what it's like
|
||||
// to do an RPC that takes a while).
|
||||
if (adder == 1)
|
||||
SLEEP(2);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,21 +54,24 @@ int
|
||||
main(int const,
|
||||
const char ** const) {
|
||||
|
||||
xmlrpc_c::registry myRegistry;
|
||||
try {
|
||||
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);
|
||||
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);
|
||||
} catch (exception const& e) {
|
||||
cerr << "Something failed. " << e.what() << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user