24 #include <blackboard/net/interface_listener.h> 25 #include <blackboard/net/messages.h> 27 #include <blackboard/blackboard.h> 28 #include <interface/interface.h> 30 #include <netcomm/fawkes/hub.h> 31 #include <netcomm/fawkes/message.h> 32 #include <netcomm/fawkes/component_ids.h> 33 #include <logging/liblogger.h> 38 #include <arpa/inet.h> 68 __blackboard = blackboard;
69 __interface = interface;
90 size_t payload_size =
sizeof(
bb_idata_msg_t) + interface->datasize();
91 void *payload = malloc(payload_size);
93 dm->
serial = htonl(interface->serial());
94 dm->
data_size = htonl(interface->datasize());
95 memcpy((
char *)payload +
sizeof(
bb_idata_msg_t), interface->datachunk(),
96 interface->datasize());
99 __fnh->
send(__clid, FAWKES_CID_BLACKBOARD, MSG_BB_DATA_CHANGED, payload, payload_size);
113 void *payload = calloc(1, payload_size);
115 dm->
serial = htonl(interface->serial());
116 strncpy(dm->
msg_type, message->type(), __INTERFACE_MESSAGE_TYPE_SIZE);
117 dm->
data_size = htonl(message->datasize());
118 dm->
msgid = htonl(message->id());
119 dm->
hops = htonl(message->hops());
121 message->datasize());
124 __fnh->
send(__clid, FAWKES_CID_BLACKBOARD, MSG_BB_INTERFACE_MESSAGE, payload, payload_size);
136 BlackBoardNetHandlerInterfaceListener::send_event_serial(
Interface *interface,
138 unsigned int event_serial)
155 unsigned int instance_serial)
throw()
157 send_event_serial(interface, MSG_BB_WRITER_ADDED, instance_serial);
163 unsigned int instance_serial)
throw()
165 send_event_serial(interface, MSG_BB_WRITER_REMOVED, instance_serial);
171 unsigned int instance_serial)
throw()
173 send_event_serial(interface, MSG_BB_READER_ADDED, instance_serial);
179 unsigned int instance_serial)
throw()
181 send_event_serial(interface, MSG_BB_READER_REMOVED, instance_serial);
virtual bool bb_interface_message_received(Interface *interface, Message *message)
BlackBoard message received notification.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
virtual void bb_interface_reader_added(Interface *interface, unsigned int instance_serial)
A reading instance has been opened for a watched interface.
Message to identify an two interface instances.
Fawkes library namespace.
void bbil_add_writer_interface(Interface *interface)
Add an interface to the writer addition/removal watch list.
virtual void unregister_listener(BlackBoardInterfaceListener *listener)
Unregister BB interface listener.
char msg_type[__INTERFACE_MESSAGE_TYPE_SIZE]
message type
Base class for all Fawkes BlackBoard interfaces.
uint32_t event_serial
instance serial to unique identify instance that caused the event.
virtual void register_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL)
Register BB event listener.
virtual ~BlackBoardNetHandlerInterfaceListener()
Destructor.
Base class for exceptions in Fawkes.
unsigned short serial() const
Get instance serial of interface.
virtual void send(FawkesNetworkMessage *msg)=0
Method to send a message to a specific client.
uint32_t serial
instance serial to unique identify own instance
virtual void bb_interface_data_changed(Interface *interface)
BlackBoard data changed notification.
uint32_t data_size
data for message
virtual void bb_interface_reader_removed(Interface *interface, unsigned int instance_serial)
A reading instance has been closed for a watched interface.
static void log_warn(const char *component, const char *format,...)
Log warning message.
bool is_writer() const
Check if this is a writing instance.
void bbil_add_reader_interface(Interface *interface)
Add an interface to the reader addition/removal watch list.
uint32_t serial
interface instance serial
virtual void bb_interface_writer_removed(Interface *interface, unsigned int instance_serial)
A writing instance has been closed for a watched interface.
uint32_t serial
instance serial to unique identify this instance
virtual void bb_interface_writer_added(Interface *interface, unsigned int instance_serial)
A writing instance has been opened for a watched interface.
const char * bbil_name() const
Get BBIL name.
The BlackBoard abstract class.
uint32_t data_size
size in bytes of the following data.
void bbil_add_message_interface(Interface *interface)
Add an interface to the message received watch list.
BlackBoardNetHandlerInterfaceListener(BlackBoard *blackboard, Interface *interface, FawkesNetworkHub *hub, unsigned int clid)
Constructor.
BlackBoard interface listener.
uint32_t hops
number of hops this message already passed
void bbil_add_data_interface(Interface *interface)
Add an interface to the data modification watch list.