Fawkes API
Fawkes Development Version
|
Network handler abstract base class. More...
#include <netcomm/fawkes/handler.h>
Public Member Functions | |
FawkesNetworkHandler (unsigned short int id) | |
Constructor. More... | |
virtual | ~FawkesNetworkHandler () |
Destructor. More... | |
unsigned short int | id () const |
Get the component ID for this handler. More... | |
virtual void | handle_network_message (FawkesNetworkMessage *msg)=0 |
Called for incoming messages that are addressed to the correct component ID. More... | |
virtual void | client_connected (unsigned int clid)=0 |
Called when a new client connected. More... | |
virtual void | client_disconnected (unsigned int clid)=0 |
Called when a client disconnected. More... | |
Network handler abstract base class.
This class shall be extended by threads that want to use the Fawkes network connection.
fawkes::FawkesNetworkHandler::FawkesNetworkHandler | ( | unsigned short int | id | ) |
Constructor.
id | the component ID this handlers wants to handle. |
Definition at line 62 of file handler.cpp.
References id().
|
virtual |
Destructor.
Definition at line 69 of file handler.cpp.
|
pure virtual |
Called when a new client connected.
If any actions need to be taken on your side this is the place to do it.
clid | client ID of new client |
Implemented in fawkes::NetworkLogger, fawkes::PluginNetworkHandler, fawkes::ConfigNetworkHandler, fawkes::BlackBoardNetworkHandler, and ExampleNetworkThread.
|
pure virtual |
Called when a client disconnected.
If any actions need to be taken on your side this is the place to do it. Note that you cannot send any further messages to this client!
clid | client ID of disconnected client |
Implemented in fawkes::NetworkLogger, fawkes::PluginNetworkHandler, fawkes::ConfigNetworkHandler, fawkes::BlackBoardNetworkHandler, and ExampleNetworkThread.
|
pure virtual |
Called for incoming messages that are addressed to the correct component ID.
Note that this message should be processed really really fast! A good idea is to enqueue the message in an inbound queue (remember to ref() it!) and then process it in the next run of loop() or wakeup a processing thread.
msg | message to handle. If you want to keep this message you have to ref() it! It is guaranteed that the message will not be erased during the handleNetworkMessage() run, but afterwards no guarantee is made. So if you want to store the message internally for example for later processing you have to reference the message. |
Implemented in fawkes::NetworkLogger, fawkes::PluginNetworkHandler, fawkes::ConfigNetworkHandler, fawkes::BlackBoardNetworkHandler, and ExampleNetworkThread.
unsigned short int fawkes::FawkesNetworkHandler::id | ( | ) | const |
Get the component ID for this handler.
Definition at line 78 of file handler.cpp.
Referenced by fawkes::FawkesNetworkServerThread::add_handler(), FawkesNetworkHandler(), and fawkes::FawkesNetworkServerThread::remove_handler().