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;
154 for (V_CachedXmlRpcClient::iterator i =
clients_.begin();
171 for (
int wait_count = 0; !
clients_.empty() && wait_count < 10; wait_count++)
181 S_ASyncXMLRPCConnection::iterator it =
connections_.begin();
182 S_ASyncXMLRPCConnection::iterator end =
connections_.end();
183 for (; it != end; ++it)
205 if (response.
getType() != XmlRpcValue::TypeArray)
211 if (response.
size() != 2 && response.
size() != 3)
217 if (response[0].getType() != XmlRpcValue::TypeInt)
219 ROSCPP_LOG_DEBUG(
"XML-RPC call [%s] didn't return a int as the 1st element",
223 int status_code = response[0];
224 if (response[1].getType() != XmlRpcValue::TypeString)
226 ROSCPP_LOG_DEBUG(
"XML-RPC call [%s] didn't return a string as the 2nd element",
230 std::string status_string = response[1];
231 if (status_code != 1)
234 method.c_str(), status_code, status_string.c_str());
237 if (response.
size() > 2)
239 payload = response[2];
243 std::string empty_array =
"<value><array><data></data></array></value>";
252 disableAllSignalsInThisThread();
260 for (; it != end; ++it)
286 S_ASyncXMLRPCConnection::iterator it =
connections_.begin();
287 S_ASyncXMLRPCConnection::iterator end =
connections_.end();
288 for (; it != end; ++it)
301 for (; it != end; ++it)
319 for (V_CachedXmlRpcClient::iterator i =
clients_.begin();
325 if (i->client_->getHost() == host &&
326 i->client_->getPort() == port &&
327 i->client_->getUri() == uri)
335 else if (i->last_use_time_ + CachedXmlRpcClient::s_zombie_time_ <
SteadyTime::now())
371 for (V_CachedXmlRpcClient::iterator i =
clients_.begin();
413 info.
name = function_name;
void execute(XmlRpcValue ¶ms, XmlRpcValue &result)
volatile bool unbind_requested_
boost::mutex added_connections_mutex_
ROSCPP_DECL 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_
ROSCPP_DECL XmlRpc::XmlRpcValue responseInt(int code, const std::string &msg, int response)
bool bindAndListen(int port, int backlog=5)
V_CachedXmlRpcClient clients_
ROSCPP_DECL XmlRpc::XmlRpcValue responseStr(int code, const std::string &msg, const std::string &response)
boost::mutex functions_mutex_
S_ASyncXMLRPCConnection connections_
void removeASyncConnection(const ASyncXMLRPCConnectionPtr &conn)
XmlRpcDispatch * get_dispatch()
boost::mutex removed_connections_mutex_
#define ROSCPP_LOG_DEBUG(...)
Type const & getType() const
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)
ROSCPP_DECL void unsubscribeCachedParam(const std::string &key)
Unsubscribe cached parameter from the master.
void releaseXMLRPCClient(XmlRpc::XmlRpcClient *c)
S_ASyncXMLRPCConnection removed_connections_
void unbind(const std::string &function_name)
S_ASyncXMLRPCConnection added_connections_
XmlRpc::XmlRpcServer server_