00001 #ifndef __PINGPONG_H_ 00002 #define __PINGPONG_H_ 00003 00004 #include "ariba/ariba.h" 00005 #include "ariba/utility/system/StartupInterface.h" 00006 #include "ariba/utility/system/Timer.h" 00007 00008 #include <vector> 00009 00010 using namespace ariba; 00011 using ariba::utility::StartupInterface; 00012 using ariba::utility::Timer; 00013 00014 namespace ariba { 00015 namespace application { 00016 namespace dhttest { 00017 00018 using namespace std; 00019 00020 /* 00021 * DHTTest main class 00022 */ 00023 class DHTTest: public NodeListener, 00024 public CommunicationListener, 00025 public StartupInterface, 00026 public Timer { 00027 00028 use_logging_h(DHTTest); 00029 00030 public: 00031 DHTTest(); 00032 virtual ~DHTTest(); 00033 00034 protected: 00035 // communication listener interface 00036 virtual bool onLinkRequest(const NodeID& remote); 00037 virtual void onLinkUp(const LinkID& lnk, const NodeID& remote); 00038 virtual void onLinkDown(const LinkID& lnk, const NodeID& remote); 00039 virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote); 00040 virtual void onLinkFail(const LinkID& lnk, const NodeID& remote); 00041 00042 // the dht message handler (for answers to get() requests) 00043 virtual void onKeyValue( const Data& key, const vector<Data>& value ); 00044 00045 // node listener interface 00046 virtual void onJoinCompleted(const SpoVNetID& vid); 00047 virtual void onJoinFailed(const SpoVNetID& vid); 00048 virtual void onLeaveCompleted(const SpoVNetID& vid); 00049 virtual void onLeaveFailed(const SpoVNetID& vid); 00050 00051 // startup wrapper interface 00052 virtual void startup(); 00053 virtual void shutdown(); 00054 00055 // timer events 00056 virtual void eventFunction(); 00057 00058 // helper functions to convert from string to Data and visa versa 00059 Data stod(string s); 00060 string dtos(Data d); 00061 00062 private: 00063 // the ariba module and a node 00064 AribaModule* ariba; 00065 Node* node; 00066 string name; 00067 00068 // this is for the specific dht test 00069 string key; 00070 string data; 00071 int counter; 00072 00073 // the dht test service id 00074 static ServiceID DHTTEST_SERVICEID; 00075 00076 }; 00077 00078 // needed for simulation support 00079 ARIBA_SIMULATION_SERVICE(DHTTest); 00080 00081 }}} // namespace ariba, application, pingpong 00082 00083 #endif // __DHTTEST_H_