source: sample/pingpong/PingPong.h@ 12765

Last change on this file since 12765 was 12063, checked in by hock@…, 11 years ago

..

File size: 1.9 KB
Line 
1#ifndef __PINGPONG_H_
2#define __PINGPONG_H_
3
4#include "ariba/ariba.h"
5#include "PingPongMessage.h"
6#include "ariba/utility/system/StartupInterface.h"
7#include "ariba/utility/system/Timer.h"
8
9#include <vector>
10
11using namespace ariba;
12using ariba::utility::StartupInterface;
13using ariba::utility::Timer;
14
15namespace ariba {
16namespace application {
17namespace pingpong {
18
19using namespace std;
20
21/**
22 * The PingPong main class
23 * This class implements an example service for demonstration purposes
24 * The pingpong class sends and receives messages between two SpoVNet
25 * instances
26 */
27class PingPong: public NodeListener,
28 public CommunicationListener,
29 public StartupInterface,
30 public Timer {
31
32 use_logging_h(PingPong);
33
34public:
35 PingPong( string config );
36 virtual ~PingPong();
37
38protected:
39 // communication listener interface
40 virtual bool onLinkRequest(const NodeID& remote);
41 virtual void onMessage(const DataMessage& msg, const NodeID& remote,
42 const LinkID& lnk = LinkID::UNSPECIFIED);
43 virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
44 virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
45 virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote);
46 virtual void onLinkFail(const LinkID& lnk, const NodeID& remote);
47
48 // node listener interface
49 virtual void onJoinCompleted(const SpoVNetID& vid);
50 virtual void onJoinFailed(const SpoVNetID& vid);
51 virtual void onLeaveCompleted(const SpoVNetID& vid);
52 virtual void onLeaveFailed(const SpoVNetID& vid);
53
54 // startup wrapper interface
55 virtual void startup();
56 virtual void shutdown();
57
58 // timer events
59 virtual void eventFunction();
60
61private:
62 Node node;
63 string name;
64 int counter;
65 vector<string> names;
66
67 // the ping pong service id
68 static ServiceID PINGPONG_SERVICEID;
69
70 // the current ping id
71 unsigned long pingId;
72
73 string config_file;
74};
75
76}}} // namespace ariba, application, pingpong
77
78#endif // __PINGPONG_H_
Note: See TracBrowser for help on using the repository browser.