Fawkes API  Fawkes Development Version
protobuf_comm::ProtobufStreamClient Class Reference

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...
 
MessageRegistermessage_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...
 

Detailed Description

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.

Author
Tim Niemueller

Definition at line 59 of file client.h.

Constructor & Destructor Documentation

◆ ProtobufStreamClient() [1/3]

protobuf_comm::ProtobufStreamClient::ProtobufStreamClient ( )

Constructor.

Definition at line 57 of file client.cpp.

◆ ProtobufStreamClient() [2/3]

protobuf_comm::ProtobufStreamClient::ProtobufStreamClient ( std::vector< std::string > &  proto_path)

Constructor.

Parameters
proto_pathfile 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.

◆ ProtobufStreamClient() [3/3]

protobuf_comm::ProtobufStreamClient::ProtobufStreamClient ( MessageRegister mr,
frame_header_version_t  header_version = PB_FRAME_V2 
)

Constructor.

Parameters
mrmessage register to use to (de)serialize messages
header_versionprotobuf protocol frame header version to use,

Definition at line 97 of file client.cpp.

◆ ~ProtobufStreamClient()

protobuf_comm::ProtobufStreamClient::~ProtobufStreamClient ( )

Destructor.

Definition at line 118 of file client.cpp.

Member Function Documentation

◆ async_connect()

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.

Parameters
hosthost to connect to
portTCP 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().

◆ connected()

bool protobuf_comm::ProtobufStreamClient::connected ( ) const
inline

Check if client is connected.

Returns
true if the client is connected, false otherwise

Definition at line 79 of file client.h.

References send().

◆ disconnect()

◆ message_register()

MessageRegister& protobuf_comm::ProtobufStreamClient::message_register ( )
inline

Get the client's message register.

Returns
message register

Definition at line 70 of file client.h.

References async_connect(), and disconnect().

◆ send() [1/3]

◆ send() [2/3]

void protobuf_comm::ProtobufStreamClient::send ( std::shared_ptr< google::protobuf::Message >  m)

Send a message to the server.

Parameters
mmessage 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().

◆ send() [3/3]

void protobuf_comm::ProtobufStreamClient::send ( google::protobuf::Message &  m)

Send a message to the server.

Parameters
mmessage 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().

◆ signal_connected()

boost::signals2::signal<void ()>& protobuf_comm::ProtobufStreamClient::signal_connected ( )
inline

Signal that is invoked when the connection has been established.

Returns
signal

Definition at line 105 of file client.h.

Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_client_connect().

◆ signal_disconnected()

boost::signals2::signal<void (const boost::system::error_code &)>& protobuf_comm::ProtobufStreamClient::signal_disconnected ( )
inline

Signal that is invoked when the connection is closed.

Returns
signal

Definition at line 111 of file client.h.

Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_client_connect().

◆ signal_receive_failed()

boost::signals2::signal<void (uint16_t, uint16_t, std::string)>& protobuf_comm::ProtobufStreamClient::signal_receive_failed ( )
inline

Signal that is invoked when receiving a message failed.

Returns
signal

Definition at line 99 of file client.h.

Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_client_connect().

◆ signal_received()

boost::signals2::signal<void (uint16_t, uint16_t, std::shared_ptr<google::protobuf::Message>)>& protobuf_comm::ProtobufStreamClient::signal_received ( )
inline

Signal that is invoked when a message has been received.

Returns
signal

Definition at line 93 of file client.h.

Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_client_connect().


The documentation for this class was generated from the following files: