Handles a connection to a service. If it's a non-persistent client, automatically disconnects when its first service call has finished. More...
#include <service_server_link.h>
Classes | |
struct | CallInfo |
Public Types | |
typedef std::map< std::string, std::string > | M_string |
Public Member Functions | |
bool | call (const SerializedMessage &req, SerializedMessage &resp) |
Blocking call the service this client is connected to. More... | |
const ConnectionPtr & | getConnection () const |
const std::string & | getRequestMD5Sum () const |
const std::string & | getResponseMD5Sum () const |
const std::string & | getServiceName () const |
bool | initialize (const ConnectionPtr &connection) |
bool | isPersistent () const |
Returns whether this is a persistent connection. More... | |
bool | isValid () const |
Returns whether this client is still valid, ie. its connection has not been dropped. More... | |
ServiceServerLink (const std::string &service_name, bool persistent, const std::string &request_md5sum, const std::string &response_md5sum, const M_string &header_values) | |
virtual | ~ServiceServerLink () |
Private Types | |
typedef boost::shared_ptr< CallInfo > | CallInfoPtr |
typedef std::queue< CallInfoPtr > | Q_CallInfo |
Private Member Functions | |
void | callFinished () |
Called when the currently queued call has finished. Clears out the current call, notifying it that it has finished, then calls processNextCall() More... | |
void | cancelCall (const CallInfoPtr &info) |
Cancel a queued call, notifying it that it has failed. More... | |
void | clearCalls () |
Clear all calls, notifying them that they've failed. More... | |
void | onConnectionDropped (const ConnectionPtr &conn) |
bool | onHeaderReceived (const ConnectionPtr &conn, const Header &header) |
void | onHeaderWritten (const ConnectionPtr &conn) |
void | onRequestWritten (const ConnectionPtr &conn) |
void | onResponse (const ConnectionPtr &conn, const boost::shared_array< uint8_t > &buffer, uint32_t size, bool success) |
void | onResponseOkAndLength (const ConnectionPtr &conn, const boost::shared_array< uint8_t > &buffer, uint32_t size, bool success) |
void | processNextCall () |
Pops the next call off the queue if one is available. If this is a non-persistent connection and the queue is empty it will also drop the connection. More... | |
Private Attributes | |
Q_CallInfo | call_queue_ |
boost::mutex | call_queue_mutex_ |
ConnectionPtr | connection_ |
CallInfoPtr | current_call_ |
bool | dropped_ |
M_string | extra_outgoing_header_values_ |
bool | header_read_ |
bool | header_written_ |
bool | persistent_ |
std::string | request_md5sum_ |
std::string | response_md5sum_ |
std::string | service_name_ |
Handles a connection to a service. If it's a non-persistent client, automatically disconnects when its first service call has finished.
Definition at line 59 of file service_server_link.h.
|
private |
Definition at line 77 of file service_server_link.h.
typedef std::map<std::string, std::string> ros::ServiceServerLink::M_string |
Definition at line 81 of file service_server_link.h.
|
private |
Definition at line 78 of file service_server_link.h.
ros::ServiceServerLink::ServiceServerLink | ( | const std::string & | service_name, |
bool | persistent, | ||
const std::string & | request_md5sum, | ||
const std::string & | response_md5sum, | ||
const M_string & | header_values | ||
) |
Definition at line 50 of file service_server_link.cpp.
|
virtual |
Definition at line 63 of file service_server_link.cpp.
bool ros::ServiceServerLink::call | ( | const SerializedMessage & | req, |
SerializedMessage & | resp | ||
) |
Blocking call the service this client is connected to.
If there is already a call happening in another thread, this will queue up the call and still block until it has finished.
Definition at line 330 of file service_server_link.cpp.
|
private |
Called when the currently queued call has finished. Clears out the current call, notifying it that it has finished, then calls processNextCall()
Definition at line 253 of file service_server_link.cpp.
|
private |
Cancel a queued call, notifying it that it has failed.
Definition at line 70 of file service_server_link.cpp.
|
private |
Clear all calls, notifying them that they've failed.
Definition at line 88 of file service_server_link.cpp.
|
inline |
Definition at line 97 of file service_server_link.h.
|
inline |
Definition at line 100 of file service_server_link.h.
|
inline |
Definition at line 101 of file service_server_link.h.
|
inline |
Definition at line 99 of file service_server_link.h.
bool ros::ServiceServerLink::initialize | ( | const ConnectionPtr & | connection | ) |
Definition at line 114 of file service_server_link.cpp.
|
inline |
Returns whether this is a persistent connection.
Definition at line 95 of file service_server_link.h.
bool ros::ServiceServerLink::isValid | ( | ) | const |
Returns whether this client is still valid, ie. its connection has not been dropped.
Definition at line 385 of file service_server_link.cpp.
|
private |
Definition at line 169 of file service_server_link.cpp.
|
private |
Definition at line 138 of file service_server_link.cpp.
|
private |
Definition at line 132 of file service_server_link.cpp.
|
private |
Definition at line 180 of file service_server_link.cpp.
|
private |
Definition at line 229 of file service_server_link.cpp.
|
private |
Definition at line 187 of file service_server_link.cpp.
|
private |
Pops the next call off the queue if one is available. If this is a non-persistent connection and the queue is empty it will also drop the connection.
Definition at line 281 of file service_server_link.cpp.
|
private |
Definition at line 149 of file service_server_link.h.
|
private |
Definition at line 150 of file service_server_link.h.
|
private |
Definition at line 139 of file service_server_link.h.
|
private |
Definition at line 152 of file service_server_link.h.
|
private |
Definition at line 154 of file service_server_link.h.
|
private |
Definition at line 145 of file service_server_link.h.
|
private |
Definition at line 147 of file service_server_link.h.
|
private |
Definition at line 146 of file service_server_link.h.
|
private |
Definition at line 141 of file service_server_link.h.
|
private |
Definition at line 142 of file service_server_link.h.
|
private |
Definition at line 143 of file service_server_link.h.
|
private |
Definition at line 140 of file service_server_link.h.