Fawkes API  Fawkes Development Version
handler.cpp
00001 
00002 /***************************************************************************
00003  *  handler.cpp - Fawkes network traffic handler
00004  *
00005  *  Created: Mon Nov 20 15:07:01 2006
00006  *  Copyright  2006-2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #include <netcomm/fawkes/handler.h>
00025 
00026 namespace fawkes {
00027 
00028 /** @class FawkesNetworkHandler handler.h <netcomm/fawkes/handler.h>
00029  * Network handler abstract base class.
00030  * This class shall be extended by threads that want to use the Fawkes
00031  * network connection.
00032  *
00033  * @ingroup NetComm
00034  * @author Tim Niemueller
00035  *
00036  *
00037  * @fn void FawkesNetworkHandler::handle_network_message(FawkesNetworkMessage *msg) = 0
00038  * Called for incoming messages that are addressed to the correct component ID.
00039  * Note that this message should be processed really really fast! A good idea is to enqueue
00040  * the message in an inbound queue (remember to ref() it!) and then process it in the next
00041  * run of loop() or wakeup a processing thread.
00042  * @param msg message to handle. If you want to keep this message you have to ref() it!
00043  * It is guaranteed that the message will not be erased during the handleNetworkMessage()
00044  * run, but afterwards no guarantee is made. So if you want to store the message internally
00045  * for example for later processing you have to reference the message.
00046  *
00047  * @fn void FawkesNetworkHandler::client_connected(unsigned int clid) = 0
00048  * Called when a new client connected. If any actions need to be taken on your side this
00049  * is the place to do it.
00050  * @param clid client ID of new client
00051  *
00052  * @fn void FawkesNetworkHandler::client_disconnected(unsigned int clid) = 0
00053  * Called when a client disconnected. If any actions need to be taken on your side this
00054  * is the place to do it. Note that you cannot send any further messages to this client!
00055  * @param clid client ID of disconnected client
00056  *
00057  */
00058 
00059 /** Constructor.
00060  * @param id the component ID this handlers wants to handle.
00061  */
00062 FawkesNetworkHandler::FawkesNetworkHandler(unsigned short int id)
00063 {
00064   _id = id;
00065 }
00066 
00067 
00068 /** Destructor. */
00069 FawkesNetworkHandler::~FawkesNetworkHandler()
00070 {
00071 }
00072 
00073 
00074 /** Get the component ID for this handler.
00075  * @return component ID
00076  */
00077 unsigned short int
00078 FawkesNetworkHandler::id() const
00079 {
00080   return _id;
00081 }
00082 
00083 } // end namespace fawkes