24 #include <arpa/inet.h>
25 #include <blackboard/blackboard.h>
26 #include <blackboard/net/interface_listener.h>
27 #include <blackboard/net/messages.h>
28 #include <interface/interface.h>
29 #include <logging/liblogger.h>
30 #include <netcomm/fawkes/component_ids.h>
31 #include <netcomm/fawkes/hub.h>
32 #include <netcomm/fawkes/message.h>
66 blackboard_ = blackboard;
67 interface_ = interface;
86 size_t payload_size =
sizeof(
bb_idata_msg_t) + interface->datasize();
87 void * payload = malloc(payload_size);
89 dm->
serial = interface->serial();
90 dm->
data_size = htonl(interface->datasize());
91 memcpy((
char *)payload +
sizeof(
bb_idata_msg_t), interface->datachunk(), interface->datasize());
94 fnh_->send(clid_, FAWKES_CID_BLACKBOARD, MSG_BB_DATA_REFRESHED, payload, payload_size);
107 size_t payload_size =
sizeof(
bb_idata_msg_t) + interface->datasize();
108 void * payload = malloc(payload_size);
110 dm->
serial = interface->serial();
111 dm->
data_size = htonl(interface->datasize());
112 memcpy((
char *)payload +
sizeof(
bb_idata_msg_t), interface->datachunk(), interface->datasize());
115 fnh_->send(clid_, FAWKES_CID_BLACKBOARD, MSG_BB_DATA_CHANGED, payload, payload_size);
128 void * payload = calloc(1, payload_size);
130 dm->
serial = interface->serial();
131 dm->
source = message->source_id();
132 strncpy(dm->
msg_type, message->type(), INTERFACE_MESSAGE_TYPE_SIZE_ - 1);
133 dm->
data_size = htonl(message->datasize());
134 dm->
msgid = htonl(message->id());
135 dm->
hops = htonl(message->hops());
136 memcpy((
char *)payload +
sizeof(
bb_imessage_msg_t), message->datachunk(), message->datasize());
139 fnh_->send(clid_, FAWKES_CID_BLACKBOARD, MSG_BB_INTERFACE_MESSAGE, payload, payload_size);
150 BlackBoardNetHandlerInterfaceListener::send_event_serial(
Interface * interface,
160 }
catch (Exception &e) {
168 Uuid instance_serial) noexcept
170 send_event_serial(interface, MSG_BB_WRITER_ADDED, instance_serial);
175 Uuid instance_serial) noexcept
177 send_event_serial(interface, MSG_BB_WRITER_REMOVED, instance_serial);
182 Uuid instance_serial) noexcept
184 send_event_serial(interface, MSG_BB_READER_ADDED, instance_serial);
189 Uuid instance_serial) noexcept
191 send_event_serial(interface, MSG_BB_READER_REMOVED, instance_serial);
BlackBoard interface listener.
void bbil_add_reader_interface(Interface *interface)
Add an interface to the reader addition/removal watch list.
void bbil_add_message_interface(Interface *interface)
Add an interface to the message received watch list.
void bbil_add_writer_interface(Interface *interface)
Add an interface to the writer addition/removal watch list.
const char * bbil_name() const
Get BBIL name.
void bbil_add_data_interface(Interface *interface)
Add an interface to the data modification watch list.
virtual ~BlackBoardNetHandlerInterfaceListener()
Destructor.
BlackBoardNetHandlerInterfaceListener(BlackBoard *blackboard, Interface *interface, FawkesNetworkHub *hub, unsigned int clid)
Constructor.
virtual void bb_interface_reader_removed(Interface *interface, Uuid instance_serial) noexcept
A reading instance has been closed for a watched interface.
virtual void bb_interface_data_refreshed(Interface *interface) noexcept
BlackBoard data refreshed notification.
virtual bool bb_interface_message_received(Interface *interface, Message *message) noexcept
BlackBoard message received notification.
virtual void bb_interface_reader_added(Interface *interface, Uuid instance_serial) noexcept
A reading instance has been opened for a watched interface.
virtual void bb_interface_writer_added(Interface *interface, Uuid instance_serial) noexcept
A writing instance has been opened for a watched interface.
virtual void bb_interface_writer_removed(Interface *interface, Uuid instance_serial) noexcept
A writing instance has been closed for a watched interface.
virtual void bb_interface_data_changed(Interface *interface) noexcept
BlackBoard data changed notification.
The BlackBoard abstract class.
virtual void unregister_listener(BlackBoardInterfaceListener *listener)
Unregister BB interface listener.
virtual void register_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL)
Register BB event listener.
Base class for exceptions in Fawkes.
virtual void send(FawkesNetworkMessage *msg)=0
Method to send a message to a specific client.
Base class for all Fawkes BlackBoard interfaces.
bool is_writer() const
Check if this is a writing instance.
Uuid serial() const
Get instance serial of interface.
static void log_warn(const char *component, const char *format,...)
Log warning message.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
A convenience class for universally unique identifiers (UUIDs).
Fawkes library namespace.
uint32_t data_size
size in bytes of the following data.
Uuid serial
instance serial to unique identify this instance
Message to identify an two interface instances.
Uuid event_serial
instance serial to unique identify instance that caused the event.
Uuid serial
instance serial to unique identify own instance
Uuid serial
interface instance serial
Uuid source
serial of the original message source
uint32_t data_size
data for message
char msg_type[INTERFACE_MESSAGE_TYPE_SIZE_]
message type
uint32_t hops
number of hops this message already passed