Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * hub.cpp - Fawkes network hub 00004 * 00005 * Created: Mon May 07 19:16:34 2007 00006 * Copyright 2006-2007 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/hub.h> 00025 00026 namespace fawkes { 00027 00028 /** @class FawkesNetworkHub netcomm/fawkes/hub.h 00029 * Fawkes Network Hub. 00030 * This interface is the main entry point for applications, plugins and 00031 * threads that use the Fawkes network protocol. The hub provides means for 00032 * broadcasting messages to all connected clients, for sending messages 00033 * to a specific connected client and to add and remove handlers to process 00034 * incoming messages. 00035 * 00036 * @ingroup NetComm 00037 * @author Tim Niemueller 00038 * 00039 * @fn void FawkesNetworkHub::broadcast(FawkesNetworkMessage *msg) = 0 00040 * Method to broadcast a message to all connected clients. 00041 * This method shall be implemented thus that the message is sent to all 00042 * connected clients. 00043 * @param msg message to send. 00044 * 00045 * @fn void FawkesNetworkHub::broadcast(unsigned short int component_id, unsigned short int msg_id, void *payload, unsigned int payload_size) = 0 00046 * This is an overloaded member function, provided for convenience. It 00047 * differs from the above function only in what arguments it accepts. 00048 * A FawkesNetworkMessage will be created transparently and broadcasted. 00049 * @param component_id component id 00050 * @param msg_id message id 00051 * @param payload buffer with payload 00052 * @param payload_size payload size 00053 * 00054 * @fn void FawkesNetworkHub::broadcast(unsigned short int component_id, unsigned short int msg_id) = 0 00055 * This is an overloaded member function, provided for convenience. It 00056 * differs from the above function only in what arguments it accepts. 00057 * A FawkesNetworkMessage will be created transparently and broadcasted. 00058 * This can be used for messages without payload. 00059 * @param component_id component id 00060 * @param msg_id message id 00061 * 00062 * @fn void FawkesNetworkHub::send(FawkesNetworkMessage *msg) = 0 00063 * Method to send a message to a specific client. The recipient has to 00064 * be specified in the message or sending the message will fail. 00065 * @param msg message to send 00066 * 00067 * @fn void FawkesNetworkHub::send(unsigned int to_clid, unsigned short int component_id, unsigned short int msg_id) = 0 00068 * This is an overloaded member function, provided for convenience. It 00069 * differs from the above function only in what arguments it accepts. 00070 * A FawkesNetworkMessage will be created transparently and send to 00071 * the client with the given ID. 00072 * This can be used for messages without payload. 00073 * @param to_clid client ID of recipient 00074 * @param component_id component id 00075 * @param msg_id message ID 00076 * 00077 * @fn void FawkesNetworkHub::send(unsigned int to_clid, unsigned short int component_id, unsigned short int msg_id, void *payload, unsigned int payload_size) = 0 00078 * This is an overloaded member function, provided for convenience. It 00079 * differs from the above function only in what arguments it accepts. 00080 * A FawkesNetworkMessage will be created transparently and send to 00081 * the client with the given ID. 00082 * @param to_clid client ID of recipient 00083 * @param component_id component id 00084 * @param msg_id message id 00085 * @param payload buffer with payload 00086 * @param payload_size payload size 00087 * 00088 * @fn void FawkesNetworkHub::send(unsigned int to_clid, unsigned short int component_id, unsigned short int msg_id, FawkesNetworkMessageContent *content) = 0 00089 * This is an overloaded member function, provided for convenience. It 00090 * differs from the above function only in what arguments it accepts. 00091 * A FawkesNetworkMessage will be created transparently and send to 00092 * the client with the given ID. 00093 * @param to_clid client ID of recipient 00094 * @param component_id component id 00095 * @param msg_id message id 00096 * @param content complex message content 00097 * 00098 * @fn void FawkesNetworkHub::add_handler(FawkesNetworkHandler *handler) = 0 00099 * Add a message handler. 00100 * This message handler is called for incoming messages that have an appropriate 00101 * component ID (which is supplied by the handler). 00102 * @param handler handler to add 00103 * 00104 * @fn void FawkesNetworkHub::remove_handler(FawkesNetworkHandler *handler) = 0 00105 * Remove a message handler. 00106 * The message handler is removed from the list of handlers and is no longer 00107 * called for incoming data. 00108 * @param handler handler to remove 00109 * 00110 * @fn void FawkesNetworkHub::force_send() = 0 00111 * Force sending of all pending messages. 00112 * This will order the sending of all pending outbound messages that are currently 00113 * enqueued for clients. The method will block until this is done. 00114 * It is not ensured that no messages are added during that time. Make sure that 00115 * the call constraints guarantee this. 00116 */ 00117 00118 /** Virtual empty destructor. */ 00119 FawkesNetworkHub::~FawkesNetworkHub() 00120 { 00121 } 00122 00123 } // end namespace fawkes