mirror of https://github.com/sipwise/sems.git
git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1214 8eb893ce-cfd4-0310-b710-fb5ebe64c474sayer/1.4-spce2.6
parent
0dec77b98c
commit
352b0e8d20
@ -0,0 +1,42 @@
|
||||
#include "XmlRpc.h"
|
||||
#include "TOXmlRpcClient.h"
|
||||
// Clear the referenced flag even if exceptions or errors occur.
|
||||
struct ClearFlagOnExit {
|
||||
ClearFlagOnExit(bool& flag) : _flag(flag) {}
|
||||
~ClearFlagOnExit() { _flag = false; }
|
||||
bool& _flag;
|
||||
};
|
||||
|
||||
bool TOXmlRpcClient::execute(const char* method, XmlRpcValue const& params, XmlRpcValue& result, double timeout) {
|
||||
|
||||
XmlRpcUtil::log(1, "XmlRpcClient::execute: method %s (_connectionState %d).", method, _connectionState);
|
||||
|
||||
// This is not a thread-safe operation, if you want to do multithreading, use separate
|
||||
// clients for each thread. If you want to protect yourself from multiple threads
|
||||
// accessing the same client, replace this code with a real mutex.
|
||||
if (_executing)
|
||||
return false;
|
||||
|
||||
_executing = true;
|
||||
ClearFlagOnExit cf(_executing);
|
||||
|
||||
_sendAttempts = 0;
|
||||
_isFault = false;
|
||||
|
||||
if ( ! setupConnection())
|
||||
return false;
|
||||
|
||||
if ( ! generateRequest(method, params))
|
||||
return false;
|
||||
|
||||
result.clear();
|
||||
// double msTime = -1.0; // Process until exit is called
|
||||
_disp.work(timeout);
|
||||
|
||||
if (_connectionState != IDLE || ! parseResponse(result))
|
||||
return false;
|
||||
|
||||
XmlRpcUtil::log(1, "XmlRpcClient::execute: method %s completed.", method);
|
||||
_response = "";
|
||||
return true;
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
#ifndef _TO_XMLRPCCLIENT_H
|
||||
#define _TO_XMLRPCCLIENT_H
|
||||
#include "XmlRpcClient.h"
|
||||
using namespace XmlRpc;
|
||||
|
||||
/* xmlrpc client with timeout */
|
||||
class TOXmlRpcClient : public XmlRpc::XmlRpcClient {
|
||||
public:
|
||||
TOXmlRpcClient(const char* host, int port, const char* uri=0
|
||||
#ifdef HAVE_XMLRPCPP_SSL
|
||||
, bool ssl=false
|
||||
#endif
|
||||
)
|
||||
: XmlRpcClient(host, port, uri
|
||||
#ifdef HAVE_XMLRPCPP_SSL
|
||||
, ssl
|
||||
#endif
|
||||
) { }
|
||||
|
||||
bool execute(const char* method, XmlRpcValue const& params,
|
||||
XmlRpcValue& result, double timeout);
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Reference in new issue