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 = htonl(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_CHANGED, payload, payload_size);
107 void * payload = calloc(1, payload_size);
109 dm->
serial = htonl(interface->serial());
110 strncpy(dm->
msg_type, message->type(), INTERFACE_MESSAGE_TYPE_SIZE_ - 1);
111 dm->
data_size = htonl(message->datasize());
112 dm->
msgid = htonl(message->id());
113 dm->
hops = htonl(message->hops());
114 memcpy((
char *)payload +
sizeof(
bb_imessage_msg_t), message->datachunk(), message->datasize());
117 fnh_->send(clid_, FAWKES_CID_BLACKBOARD, MSG_BB_INTERFACE_MESSAGE, payload, payload_size);
128 BlackBoardNetHandlerInterfaceListener::send_event_serial(
Interface * interface,
130 unsigned int event_serial)
138 }
catch (Exception &e) {
147 unsigned int instance_serial)
throw()
149 send_event_serial(interface, MSG_BB_WRITER_ADDED, instance_serial);
155 unsigned int instance_serial)
throw()
157 send_event_serial(interface, MSG_BB_WRITER_REMOVED, instance_serial);
163 unsigned int instance_serial)
throw()
165 send_event_serial(interface, MSG_BB_READER_ADDED, instance_serial);
171 unsigned int instance_serial)
throw()
173 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 bool bb_interface_message_received(Interface *interface, Message *message)
BlackBoard message received notification.
virtual void bb_interface_writer_removed(Interface *interface, unsigned int instance_serial)
A writing instance has been closed for a watched interface.
virtual void bb_interface_reader_added(Interface *interface, unsigned int instance_serial)
A reading instance has been opened for a watched interface.
virtual void bb_interface_reader_removed(Interface *interface, unsigned int instance_serial)
A reading instance has been closed for a watched interface.
virtual void bb_interface_data_changed(Interface *interface)
BlackBoard data changed notification.
virtual void bb_interface_writer_added(Interface *interface, unsigned int instance_serial)
A writing instance has been opened for a watched interface.
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.
unsigned short 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.
Fawkes library namespace.
uint32_t serial
instance serial to unique identify this instance
uint32_t data_size
size in bytes of the following data.
Message to identify an two interface instances.
uint32_t event_serial
instance serial to unique identify instance that caused the event.
uint32_t serial
instance serial to unique identify own instance
uint32_t serial
interface instance serial
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