32 #include "ros/common.h" 76 , name_(function_name)
82 func_(params, result);
100 static XMLRPCManagerPtr xmlrpc_manager = boost::make_shared<XMLRPCManager>();
101 return xmlrpc_manager;
104 XMLRPCManager::XMLRPCManager()
106 , shutting_down_(false)
107 , unbind_requested_(false)
128 std::stringstream ss;
151 for (V_CachedXmlRpcClient::iterator i =
clients_.begin();
168 for (
int wait_count = 0; !
clients_.empty() && wait_count < 10; wait_count++)
178 S_ASyncXMLRPCConnection::iterator it =
connections_.begin();
179 S_ASyncXMLRPCConnection::iterator end =
connections_.end();
180 for (; it != end; ++it)
202 if (response.
getType() != XmlRpcValue::TypeArray)
208 if (response.
size() != 2 && response.
size() != 3)
214 if (response[0].getType() != XmlRpcValue::TypeInt)
216 ROSCPP_LOG_DEBUG(
"XML-RPC call [%s] didn't return a int as the 1st element",
220 int status_code = response[0];
221 if (response[1].getType() != XmlRpcValue::TypeString)
223 ROSCPP_LOG_DEBUG(
"XML-RPC call [%s] didn't return a string as the 2nd element",
227 std::string status_string = response[1];
228 if (status_code != 1)
231 method.c_str(), status_code, status_string.c_str());
234 if (response.
size() > 2)
236 payload = response[2];
240 std::string empty_array =
"<value><array><data></data></array></value>";
249 disableAllSignalsInThisThread();
257 for (; it != end; ++it)
283 S_ASyncXMLRPCConnection::iterator it =
connections_.begin();
284 S_ASyncXMLRPCConnection::iterator end =
connections_.end();
285 for (; it != end; ++it)
298 for (; it != end; ++it)
316 for (V_CachedXmlRpcClient::iterator i =
clients_.begin();
322 if (i->client_->getHost() == host &&
323 i->client_->getPort() == port &&
324 i->client_->getUri() == uri)
332 else if (i->last_use_time_ + CachedXmlRpcClient::s_zombie_time_ <
SteadyTime::now())
368 for (V_CachedXmlRpcClient::iterator i =
clients_.begin();
410 info.
name = function_name;
void execute(XmlRpcValue ¶ms, XmlRpcValue &result)
volatile bool unbind_requested_
boost::mutex added_connections_mutex_
XmlRpc::XmlRpcValue responseBool(int code, const std::string &msg, bool response)
M_StringToFuncInfo functions_
void getPid(const XmlRpcValue ¶ms, XmlRpcValue &result)
bool validateXmlrpcResponse(const std::string &method, XmlRpc::XmlRpcValue &response, XmlRpc::XmlRpcValue &payload)
Validate an XML/RPC response.
boost::thread server_thread_
XmlRpc::XmlRpcValue responseInt(int code, const std::string &msg, int response)
bool bindAndListen(int port, int backlog=5)
V_CachedXmlRpcClient clients_
XmlRpc::XmlRpcValue responseStr(int code, const std::string &msg, const std::string &response)
boost::mutex functions_mutex_
Type const & getType() const
S_ASyncXMLRPCConnection connections_
void removeASyncConnection(const ASyncXMLRPCConnectionPtr &conn)
XmlRpcDispatch * get_dispatch()
boost::mutex removed_connections_mutex_
#define ROSCPP_LOG_DEBUG(...)
ROSCPP_DECL const std::string & getHost()
boost::function< void(XmlRpc::XmlRpcValue &, XmlRpc::XmlRpcValue &)> XMLRPCFunc
boost::mutex clients_mutex_
void addASyncConnection(const ASyncXMLRPCConnectionPtr &conn)
XMLRPCCallWrapperPtr wrapper
bool bind(const std::string &function_name, const XMLRPCFunc &cb)
XmlRpc::XmlRpcClient * getXMLRPCClient(const std::string &host, const int port, const std::string &uri)
XMLRPCCallWrapper(const std::string &function_name, const XMLRPCFunc &cb, XmlRpcServer *s)
void releaseXMLRPCClient(XmlRpc::XmlRpcClient *c)
S_ASyncXMLRPCConnection removed_connections_
void unbind(const std::string &function_name)
S_ASyncXMLRPCConnection added_connections_
XmlRpc::XmlRpcServer server_