Network handler abstract base class. More...
#include <netcomm/fawkes/handler.h>
Public Member Functions | |
FawkesNetworkHandler (unsigned short int id) | |
Constructor. | |
virtual | ~FawkesNetworkHandler () |
Destructor. | |
unsigned short int | id () const |
Get the component ID for this handler. | |
virtual void | handle_network_message (FawkesNetworkMessage *msg)=0 |
Called for incoming messages that are addressed to the correct component ID. | |
virtual void | client_connected (unsigned int clid)=0 |
Called when a new client connected. | |
virtual void | client_disconnected (unsigned int clid)=0 |
Called when a client disconnected. |
Network handler abstract base class.
This class shall be extended by threads that want to use the Fawkes network connection.
Definition at line 31 of file handler.h.
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.
fawkes::FawkesNetworkHandler::~FawkesNetworkHandler | ( | ) | [virtual] |
Destructor.
Definition at line 69 of file handler.cpp.
void fawkes::FawkesNetworkHandler::client_connected | ( | unsigned int | clid | ) | [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::BlackBoardNetworkHandler, fawkes::ConfigNetworkHandler, fawkes::NetworkLogger, fawkes::PluginNetworkHandler, and ExampleNetworkThread.
void fawkes::FawkesNetworkHandler::client_disconnected | ( | unsigned int | clid | ) | [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::BlackBoardNetworkHandler, fawkes::ConfigNetworkHandler, fawkes::NetworkLogger, fawkes::PluginNetworkHandler, and ExampleNetworkThread.
void fawkes::FawkesNetworkHandler::handle_network_message | ( | FawkesNetworkMessage * | msg | ) | [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::BlackBoardNetworkHandler, fawkes::ConfigNetworkHandler, fawkes::NetworkLogger, fawkes::PluginNetworkHandler, 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(), and fawkes::FawkesNetworkServerThread::remove_handler().