Fawkes API
Fawkes Development Version
|
Stream client for protobuf message transmission. More...
#include <>>
Public Member Functions | |
ProtobufStreamClient () | |
Constructor. More... | |
ProtobufStreamClient (std::vector< std::string > &proto_path) | |
Constructor. More... | |
ProtobufStreamClient (MessageRegister *mr, frame_header_version_t header_version=PB_FRAME_V2) | |
Constructor. More... | |
~ProtobufStreamClient () | |
Destructor. More... | |
MessageRegister & | message_register () |
Get the client's message register. More... | |
void | async_connect (const char *host, unsigned short port) |
Asynchronous connect. More... | |
void | disconnect () |
Disconnect from remote host. More... | |
bool | connected () const |
Check if client is connected. More... | |
void | send (uint16_t component_id, uint16_t msg_type, google::protobuf::Message &m) |
Send a message to the server. More... | |
void | send (std::shared_ptr< google::protobuf::Message > m) |
Send a message to the server. More... | |
void | send (google::protobuf::Message &m) |
Send a message to the server. More... | |
boost::signals2::signal< void(uint16_t, uint16_t, std::shared_ptr< google::protobuf::Message >)> & | signal_received () |
Signal that is invoked when a message has been received. More... | |
boost::signals2::signal< void(uint16_t, uint16_t, std::string)> & | signal_receive_failed () |
Signal that is invoked when receiving a message failed. More... | |
boost::signals2::signal< void()> & | signal_connected () |
Signal that is invoked when the connection has been established. More... | |
boost::signals2::signal< void(const boost::system::error_code &)> & | signal_disconnected () |
Signal that is invoked when the connection is closed. More... | |
Stream client for protobuf message transmission.
The client opens a TCP connection (IPv4) to a specified server and send and receives messages to the remote.
protobuf_comm::ProtobufStreamClient::ProtobufStreamClient | ( | ) |
Constructor.
Definition at line 57 of file client.cpp.
protobuf_comm::ProtobufStreamClient::ProtobufStreamClient | ( | std::vector< std::string > & | proto_path | ) |
Constructor.
proto_path | file paths to search for proto files. All message types within these files will automatically be registered and available for dynamic message creation. |
Definition at line 77 of file client.cpp.
protobuf_comm::ProtobufStreamClient::ProtobufStreamClient | ( | MessageRegister * | mr, |
frame_header_version_t | header_version = PB_FRAME_V2 |
||
) |
Constructor.
mr | message register to use to (de)serialize messages |
header_version | protobuf protocol frame header version to use, |
Definition at line 97 of file client.cpp.
protobuf_comm::ProtobufStreamClient::~ProtobufStreamClient | ( | ) |
Destructor.
Definition at line 118 of file client.cpp.
void protobuf_comm::ProtobufStreamClient::async_connect | ( | const char * | host, |
unsigned short | port | ||
) |
Asynchronous connect.
This triggers connection establishment. The method does not block, i.e. it returns immediately and does not wait for the connection to be established.
host | host to connect to |
port | TCP port to connect to |
Definition at line 154 of file client.cpp.
Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), message_register(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_client_connect().
|
inline |
void protobuf_comm::ProtobufStreamClient::disconnect | ( | ) |
Disconnect from remote host.
Definition at line 225 of file client.cpp.
References protobuf_comm::QueueEntry::buffers, protobuf_comm::frame_header_t::cipher, protobuf_comm::message_header_t::component_id, protobuf_comm::frame_header_v1_t::component_id, protobuf_comm::MessageRegister::deserialize(), protobuf_comm::frame_header_t::header_version, protobuf_comm::message_header_t::msg_type, protobuf_comm::frame_header_v1_t::msg_type, protobuf_comm::frame_header_t::payload_size, and protobuf_comm::frame_header_v1_t::payload_size.
Referenced by message_register().
|
inline |
Get the client's message register.
Definition at line 70 of file client.h.
References async_connect(), and disconnect().
void protobuf_comm::ProtobufStreamClient::send | ( | uint16_t | component_id, |
uint16_t | msg_type, | ||
google::protobuf::Message & | m | ||
) |
Send a message to the server.
component_id | ID of the component to address |
msg_type | numeric message type |
m | message to send |
Definition at line 351 of file client.cpp.
References protobuf_comm::QueueEntry::buffers, protobuf_comm::message_header_t::component_id, protobuf_comm::frame_header_v1_t::component_id, protobuf_comm::QueueEntry::frame_header, protobuf_comm::QueueEntry::frame_header_v1, protobuf_comm::QueueEntry::message_header, protobuf_comm::message_header_t::msg_type, protobuf_comm::frame_header_v1_t::msg_type, protobuf_comm::frame_header_t::payload_size, protobuf_comm::frame_header_v1_t::payload_size, protobuf_comm::MessageRegister::serialize(), and protobuf_comm::QueueEntry::serialized_message.
Referenced by connected(), and send().
void protobuf_comm::ProtobufStreamClient::send | ( | std::shared_ptr< google::protobuf::Message > | m | ) |
Send a message to the server.
m | message to send, the message must be of a type with a suitable CompType enum indicating component ID and message type. |
Definition at line 428 of file client.cpp.
References send().
void protobuf_comm::ProtobufStreamClient::send | ( | google::protobuf::Message & | m | ) |
Send a message to the server.
m | message to send, the message must be of a type with a suitable CompType enum indicating component ID and message type. |
Definition at line 396 of file client.cpp.
References send().
|
inline |
Signal that is invoked when the connection has been established.
Definition at line 105 of file client.h.
Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_client_connect().
|
inline |
Signal that is invoked when the connection is closed.
Definition at line 111 of file client.h.
Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_client_connect().
|
inline |
Signal that is invoked when receiving a message failed.
Definition at line 99 of file client.h.
Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_client_connect().
|
inline |
Signal that is invoked when a message has been received.
Definition at line 93 of file client.h.
Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_client_connect().