44 #include <boost/bind.hpp> 79 std::string
md5sum, service, client_callerid;
80 if (!header.
getValue(
"md5sum", md5sum)
81 || !header.
getValue(
"service", service)
82 || !header.
getValue(
"callerid", client_callerid))
84 std::string msg(
"bogus tcpros header. did not have the " 85 "required elements: md5sum, service, callerid");
93 std::string persistent;
94 if (header.
getValue(
"persistent", persistent))
96 if (persistent ==
"1" || persistent ==
"true")
102 ROSCPP_LOG_DEBUG(
"Service client [%s] wants service [%s] with md5sum [%s]", client_callerid.c_str(), service.c_str(), md5sum.c_str());
106 std::string msg = std::string(
"received a tcpros connection for a " 107 "nonexistent service [") +
108 service + std::string(
"].");
115 if (ss->getMD5Sum() != md5sum &&
116 (md5sum != std::string(
"*") && ss->getMD5Sum() != std::string(
"*")))
118 std::string msg = std::string(
"client wants service ") + service +
119 std::string(
" to have md5sum ") + md5sum +
120 std::string(
", but it has ") + ss->getMD5Sum() +
121 std::string(
". Dropping connection.");
135 std::string msg = std::string(
"received a tcpros connection for a " 136 "nonexistent service [") +
137 service + std::string(
"].");
150 m[
"request_type"] = ss->getRequestDataType();
151 m[
"response_type"] = ss->getResponseDataType();
152 m[
"type"] = ss->getDataType();
153 m[
"md5sum"] = ss->getMD5Sum();
157 ss->addServiceClientLink(shared_from_this());
170 parent->removeServiceClientLink(shared_from_this());
189 uint32_t len = *((uint32_t*)buffer.get());
191 if (len > 1000000000)
193 ROS_ERROR(
"a message of over a gigabyte was " \
194 "predicted in tcpros. that seems highly " \
195 "unlikely, so I'll assume protocol " \
196 "synchronization is lost.");
214 parent->processRequest(buffer, size, shared_from_this());
void onRequest(const ConnectionPtr &conn, const boost::shared_array< uint8_t > &buffer, uint32_t size, bool success)
bool handleHeader(const Header &header)
void onResponseWritten(const ConnectionPtr &conn)
void onHeaderWritten(const ConnectionPtr &conn)
ROSCPP_DECL const std::string & getName()
Returns the name of the current node.
void processResponse(bool ok, const SerializedMessage &res)
Writes a response to the current request.
void onRequestLength(const ConnectionPtr &conn, const boost::shared_array< uint8_t > &buffer, uint32_t size, bool success)
ConnectionPtr connection_
static const ServiceManagerPtr & instance()
bool initialize(const ConnectionPtr &connection)
std::map< std::string, std::string > M_string
#define ROSCPP_LOG_DEBUG(...)
ServicePublicationWPtr parent_
ROSCPP_DECL bool ok()
Check whether it's time to exit.
boost::signals2::connection dropped_conn_
boost::weak_ptr< ServicePublication > ServicePublicationWPtr
boost::shared_array< uint8_t > buf
virtual ~ServiceClientLink()
void onConnectionDropped(const ConnectionPtr &conn)