22#ifndef MESSAGE_HANDLER_H
23#define MESSAGE_HANDLER_H
25#include <aspect/blackboard.h>
26#include <aspect/configurable.h>
27#include <aspect/logging.h>
28#include <core/threading/mutex.h>
29#include <core/threading/thread.h>
30#include <protobuf_comm/server.h>
36#define CFG_PREFIX "/plugins/protoboard"
38namespace protobuf_comm {
39class ProtobufStreamClient;
40class ProtobufBroadcastPeer;
45class BlackboardManager;
77 std::shared_ptr<google::protobuf::Message>
msg;
83 long int peer_create(
const std::string &host,
int port);
84 long int peer_create_local(
const std::string &host,
int send_to_port,
int recv_on_port);
87 const std::string &crypto_key =
"",
88 const std::string &cipher =
"");
92 const std::string &crypto_key =
"",
93 const std::string &cipher =
"");
101 void send(
long int peer_id, std::shared_ptr<google::protobuf::Message> msg);
110 bb_manager_ = bb_manager;
124 virtual void init()
override;
129 const std::map<long int, protobuf_comm::ProtobufBroadcastPeer *> &
138 boost::signals2::signal<void(
long, std::shared_ptr<google::protobuf::Message>)> &
141 return sig_peer_sent_;
145 peer_setup_crypto(
long int peer_id,
const std::string &crypto_key,
const std::string &cipher);
147 void handle_peer_msg(
long int peer_id,
148 boost::asio::ip::udp::endpoint & endpoint,
149 uint16_t component_id,
151 std::shared_ptr<google::protobuf::Message> msg);
152 void handle_peer_recv_error(
long int peer_id,
153 boost::asio::ip::udp::endpoint &endpoint,
155 void handle_peer_send_error(
long int peer_id, std::string msg);
157 protobuf_comm::MessageRegister *message_register_;
159 boost::signals2::signal<void(
long int, std::shared_ptr<google::protobuf::Message>)>
164 long int next_client_id_;
166 std::map<long int, protobuf_comm::ProtobufBroadcastPeer *> peers_;
168 BlackboardManager * bb_manager_;
169 std::queue<incoming_message> pb_queue_;
Thread aspect to access to BlackBoard.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
The BlackBoard abstract class.
Thread aspect to access configuration data.
Thread aspect to log output.
Mutex mutual exclusion lock.
Thread class encapsulation of pthreads.
The main thread that is woken each time a message arrives on any of the interfaces watched by a bb_if...
Receive incoming ProtoBuf messages and pass them on to the BlackboardManager for publication to the a...
fawkes::BlackBoard * get_blackboard()
Helper to give ProtoBuf converters access to the BlackBoard instance in use.
incoming_message pb_queue_pop()
void peer_destroy(long int peer_id)
Disable peer.
long int peer_create_crypto(const std::string &host, int port, const std::string &crypto_key="", const std::string &cipher="")
Enable protobuf peer.
virtual void init() override
Initialize the thread.
long int peer_create(const std::string &host, int port)
Enable protobuf peer.
long int peer_create_local(const std::string &host, int send_to_port, int recv_on_port)
Enable protobuf peer.
ProtobufThead()
Empty-initialization constructor.
void set_bb_manager(BlackboardManager *bb_manager)
Deferred initialization of the pointer to the BlackboardManager.
long int peer_create_local_crypto(const std::string &host, int send_to_port, int recv_on_port, const std::string &crypto_key="", const std::string &cipher="")
Enable protobuf peer.
void send(long int peer_id, std::shared_ptr< google::protobuf::Message > msg)
Send a ProtoBuf message to the given peer.
virtual ~ProtobufThead() override
Destructor.
Wrapper for a ProtoBuf message and its metadata.
std::shared_ptr< google::protobuf::Message > msg
The message itself.
long int peer_id
The ProtoBuf peer ID that received this message.
boost::asio::ip::udp::endpoint endpoint
The boost::asio UDP endpoint used by the receiving peer.
uint16_t component_id
The ProtoBuf component ID.
uint16_t msg_type
The ProtoBuf type ID.