source: sample/testdht/DHTTest.h@ 7834

Last change on this file since 7834 was 7468, checked in by Christoph Mayer, 15 years ago

-timer delete fix (noch auskommentiert), -interface cleanup

File size: 1.9 KB
Line 
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
10using namespace ariba;
11using ariba::utility::StartupInterface;
12using ariba::utility::Timer;
13
14namespace ariba {
15namespace application {
16namespace dhttest {
17
18using namespace std;
19
20/*
21 * DHTTest main class
22 */
23class DHTTest: public NodeListener,
24 public CommunicationListener,
25 public StartupInterface,
26 public Timer {
27
28 use_logging_h(DHTTest);
29
30public:
31 DHTTest();
32 virtual ~DHTTest();
33
34protected:
35 // communication listener interface
36 virtual bool onLinkRequest(const NodeID& remote);
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
62private:
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
79ARIBA_SIMULATION_SERVICE(DHTTest);
80
81}}} // namespace ariba, application, pingpong
82
83#endif // __DHTTEST_H_
Note: See TracBrowser for help on using the repository browser.