00001 /** 00002 * @file Platform/Aperios1.3.2/UDPHandler.h 00003 * 00004 * Class for using NetSender/NetReceivers over UDP 00005 * 00006 * @author <A href=mailto:robocup@m-wachter.de>Michael Wachter</A> 00007 * 00008 * 00009 * The UDP-Handler sends data from NetSender's via an UDP based Protocol. 00010 * If the data from the NetSender, the package, is too big for one 00011 * UDP-Package (1500 bytes) the data is split into "subpackets". 00012 * Each of this subpackets has the same packageNumber, an increasing 00013 * subPackageNumber, the complete size and the data itself. (not implemented yet) 00014 * With this information the receiving robot can put the data together into 00015 * the right order and can find out package-loss. 00016 * If the complete package is received the associated NetReceiver is called 00017 * to stream the data. 00018 * 00019 */ 00020 00021 00022 #ifndef _UDPHandler_H_ 00023 #define _UDPHandler_H_ 00024 00025 /** 00026 * 00027 */ 00028 00029 #include "UDPEndpoint.h" 00030 #include "DDPHandler.h" 00031 #include "NetHandler.h" 00032 #include "NetSender.h" 00033 #include "NetReceiver.h" 00034 #include "Tools/Player.h" 00035 #include "NetConfig.h" 00036 #include "Tools/RingBuffer.h" 00037 00038 class UDPHandler; 00039 00040 class UDPHandlerEndpoint : public UDPEndpoint , public NetHandler 00041 { 00042 public: 00043 UDPHandlerEndpoint(); 00044 ~UDPHandlerEndpoint(); 00045 virtual void onSendingDone(); 00046 virtual void onReceive(void* data, int size); 00047 virtual void sendPackage(int SenderNumber, void* package, int size); 00048 NetSenderBase* sender; 00049 NetReceiverBase* receiver; 00050 DDPHandler* ddpHandler; 00051 UDPHandler* udpHandler; 00052 int lastReceivedSerial; 00053 RingBuffer<int,10> missingSerials; 00054 int sendSerial; 00055 }; 00056 00057 00058 class UDPHandler 00059 { 00060 public: 00061 UDPHandler(); 00062 ~UDPHandler(){}; 00063 void addSenderAndReceiver(NetSenderBase& sender, NetReceiverBase& receiver); 00064 void start(); 00065 void doRegularStuff(); 00066 00067 private: 00068 int numberOfEndpoints; 00069 00070 private: 00071 UDPHandlerEndpoint endPoints[Player::numOfPlayerNumbers-1]; 00072 DDPHandler ddpHandler; 00073 }; 00074 00075 #endif
1.3.6