Fawkes API
Fawkes Development Version
|
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"
38 namespace protobuf_comm {
39 class ProtobufStreamClient;
40 class ProtobufBroadcastPeer;
43 namespace protoboard {
45 class 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);
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_;
174 #endif // MESSAGE_HANDLER_H
long int peer_id
The ProtoBuf peer ID that received this message.
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.
long int peer_create_local(const std::string &host, int send_to_port, int recv_on_port)
Enable protobuf peer.
Register to map msg type numbers to Protobuf messages.
Mutex mutual exclusion lock.
uint16_t component_id
The ProtoBuf component ID.
virtual ~ProtobufThead() override
Destructor.
long int peer_create(const std::string &host, int port)
Enable protobuf peer.
The BlackBoard abstract class.
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.
std::shared_ptr< google::protobuf::Message > msg
The message itself.
The main thread that is woken each time a message arrives on any of the interfaces watched by a bb_if...
ProtobufThead()
Empty-initialization constructor.
Wrapper for a ProtoBuf message and its metadata.
Thread aspect to access to BlackBoard.
Thread aspect to log output.
void peer_destroy(long int peer_id)
Disable peer.
uint16_t msg_type
The ProtoBuf type ID.
virtual void init() override
Initialize the thread.
Thread class encapsulation of pthreads.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
incoming_message pb_queue_pop()
Thread aspect to access configuration data.
boost::asio::ip::udp::endpoint endpoint
The boost::asio UDP endpoint used by the receiving peer.
long int peer_create_crypto(const std::string &host, int port, const std::string &crypto_key="", const std::string &cipher="")
Enable protobuf peer.
void set_bb_manager(BlackboardManager *bb_manager)
Deferred initialization of the pointer to the BlackboardManager.
void send(long int peer_id, std::shared_ptr< google::protobuf::Message > msg)
Send a ProtoBuf message to the given peer.