00001 /** 00002 * @file Platform/Aperios1.3.2/TCPHandler.h 00003 * 00004 * @author <A href=mailto:robocup@m-wachter.de>Michael Wachter</A> 00005 */ 00006 00007 #ifndef _TCPHandler_H_ 00008 #define _TCPHandler_H_ 00009 00010 class TCPHandler; 00011 00012 #include "TCPEndpoint.h" 00013 #include "NetHandler.h" 00014 #include "NetSender.h" 00015 #include "NetReceiver.h" 00016 00017 00018 /** 00019 * The associated sender first finds out the size of the data to send 00020 * and streams the data into a memory buffer. After that the sender calls 00021 * sendPackage in the TCPHandler and the TCPHandler takes care of sending 00022 * the data to the other host. 00023 * 00024 * the TCPHandler first sends the size of the data and after that the data 00025 * itself. 00026 * 00027 * If there is incomining data the TCPHandler first reads the size of the 00028 * incoming Data and after that all received data is collected in a memory 00029 * buffer until it is complete. Now the associated receiver is called to 00030 * stream the data from the buffer. 00031 */ 00032 00033 class TCPHandler : public TCPEndpoint, public NetHandler 00034 { 00035 public: 00036 TCPHandler(){}; 00037 TCPHandler(NetSenderBase& theSender, NetReceiverBase& theReceiver); 00038 void setTransmitters(NetSenderBase& theSender, NetReceiverBase& theReceiver); 00039 virtual void onReceive(void* someData, int size); /**< receives size, collects all data and calls the receiver after that */ 00040 virtual void onConnect(void); /**< sets sender active after the connection is established */ 00041 virtual void onClose(int reason); /**< sets sender inactive after disconnecting */ 00042 virtual void onSendingDone(void); /**< informs the sender that it can send again */ 00043 virtual void sendPackage(int senderNumber,void* someData,int size); /**< called by the sender to send data */ 00044 00045 private: 00046 NetReceiverBase* receiver; /**< the associated receiver */ 00047 NetSenderBase* sender; /**< the assiciated sender */ 00048 00049 void* receiveBuffer; /**< buffer where the data is stored until completly collected */ 00050 int sizeOfDataToRead; /**< size of this data */ 00051 bool sendingDone; 00052 }; 00053 00054 00055 #endif 00056 00057 /* 00058 * 00059 * Changelog : 00060 * 00061 * $Log: TCPHandler.h,v $ 00062 * Revision 1.2 2004/09/12 20:10:47 wachter 00063 * Documentation-fixes 00064 * 00065 * Revision 1.1.1.1 2004/05/22 17:23:40 cvsadm 00066 * created new repository GT2004_WM 00067 * 00068 * Revision 1.4 2004/01/20 14:21:41 wachter 00069 * - Added sender-number to NetSender 00070 * - worked on with Team-Communication 00071 * 00072 * Revision 1.3 2004/01/03 18:57:50 wachter 00073 * Debug-communication working now 00074 * 00075 * Revision 1.2 2004/01/03 16:18:25 wachter 00076 * debug-communication mostly working now 00077 * 00078 * Revision 1.1 2003/12/21 19:27:03 wachter 00079 * Added classes for Sender/Receiver over TCP and UDP. 00080 * ( PLEASE DO NOT USE THIS NOW ! ) 00081 * 00082 * 00083 */