[6760] | 1 | #ifndef __PINGPONG_H_
|
---|
| 2 | #define __PINGPONG_H_
|
---|
| 3 |
|
---|
| 4 | #include "ariba/ariba.h"
|
---|
| 5 | #include "ariba/utility/system/StartupInterface.h"
|
---|
| 6 | #include "ariba/utility/system/Timer.h"
|
---|
| 7 |
|
---|
| 8 | #include <vector>
|
---|
| 9 |
|
---|
| 10 | using namespace ariba;
|
---|
| 11 | using ariba::utility::StartupInterface;
|
---|
| 12 | using ariba::utility::Timer;
|
---|
| 13 |
|
---|
| 14 | namespace ariba {
|
---|
| 15 | namespace application {
|
---|
| 16 | namespace dhttest {
|
---|
| 17 |
|
---|
| 18 | using namespace std;
|
---|
| 19 |
|
---|
| 20 | /*
|
---|
| 21 | * DHTTest main class
|
---|
| 22 | */
|
---|
| 23 | class DHTTest: public NodeListener,
|
---|
| 24 | public CommunicationListener,
|
---|
| 25 | public StartupInterface,
|
---|
| 26 | public Timer {
|
---|
| 27 |
|
---|
| 28 | use_logging_h(DHTTest);
|
---|
| 29 |
|
---|
| 30 | public:
|
---|
| 31 | DHTTest();
|
---|
| 32 | virtual ~DHTTest();
|
---|
| 33 |
|
---|
| 34 | protected:
|
---|
| 35 | // communication listener interface
|
---|
[7468] | 36 | virtual bool onLinkRequest(const NodeID& remote);
|
---|
[6760] | 37 | virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
|
---|
| 38 | virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
|
---|
| 39 | virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote);
|
---|
| 40 | virtual void onLinkFail(const LinkID& lnk, const NodeID& remote);
|
---|
| 41 |
|
---|
| 42 | // the dht message handler (for answers to get() requests)
|
---|
| 43 | virtual void onKeyValue( const Data& key, const vector<Data>& value );
|
---|
| 44 |
|
---|
| 45 | // node listener interface
|
---|
| 46 | virtual void onJoinCompleted(const SpoVNetID& vid);
|
---|
| 47 | virtual void onJoinFailed(const SpoVNetID& vid);
|
---|
| 48 | virtual void onLeaveCompleted(const SpoVNetID& vid);
|
---|
| 49 | virtual void onLeaveFailed(const SpoVNetID& vid);
|
---|
| 50 |
|
---|
| 51 | // startup wrapper interface
|
---|
| 52 | virtual void startup();
|
---|
| 53 | virtual void shutdown();
|
---|
| 54 |
|
---|
| 55 | // timer events
|
---|
| 56 | virtual void eventFunction();
|
---|
| 57 |
|
---|
| 58 | // helper functions to convert from string to Data and visa versa
|
---|
| 59 | Data stod(string s);
|
---|
| 60 | string dtos(Data d);
|
---|
| 61 |
|
---|
| 62 | private:
|
---|
| 63 | // the ariba module and a node
|
---|
| 64 | AribaModule* ariba;
|
---|
| 65 | Node* node;
|
---|
| 66 | string name;
|
---|
| 67 |
|
---|
| 68 | // this is for the specific dht test
|
---|
| 69 | string key;
|
---|
| 70 | string data;
|
---|
| 71 | int counter;
|
---|
| 72 |
|
---|
| 73 | // the dht test service id
|
---|
| 74 | static ServiceID DHTTEST_SERVICEID;
|
---|
| 75 |
|
---|
| 76 | };
|
---|
| 77 |
|
---|
| 78 | // needed for simulation support
|
---|
| 79 | ARIBA_SIMULATION_SERVICE(DHTTest);
|
---|
| 80 |
|
---|
| 81 | }}} // namespace ariba, application, pingpong
|
---|
| 82 |
|
---|
| 83 | #endif // __DHTTEST_H_
|
---|