| 1 | #ifndef __PINGPONG_H_
|
---|
| 2 | #define __PINGPONG_H_
|
---|
| 3 |
|
---|
| 4 | #include "ariba/ariba.h"
|
---|
| 5 | #include "PingPongMessage.h"
|
---|
| 6 |
|
---|
| 7 | using namespace ariba;
|
---|
| 8 |
|
---|
| 9 | #include "ariba/utility/system/StartupInterface.h"
|
---|
| 10 | #include "ariba/utility/system/Timer.h"
|
---|
| 11 | using ariba::utility::StartupInterface;
|
---|
| 12 | using ariba::utility::Timer;
|
---|
| 13 |
|
---|
| 14 | namespace ariba {
|
---|
| 15 | namespace application {
|
---|
| 16 | namespace pingpong {
|
---|
| 17 |
|
---|
| 18 | /**
|
---|
| 19 | /* The PingPong main class
|
---|
| 20 | /* This class implements an example service for demonstration purposes
|
---|
| 21 | /* The pingpong class sends and receives messages between two SpoVNet
|
---|
| 22 | /* instances
|
---|
| 23 | **/
|
---|
| 24 | class PingPong :
|
---|
| 25 | public NodeListener,
|
---|
| 26 | public CommunicationListener,
|
---|
| 27 | public StartupInterface,
|
---|
| 28 | public Timer {
|
---|
| 29 |
|
---|
| 30 | use_logging_h(PingPong);
|
---|
| 31 |
|
---|
| 32 | public:
|
---|
| 33 | PingPong();
|
---|
| 34 | virtual ~PingPong();
|
---|
| 35 |
|
---|
| 36 | protected:
|
---|
| 37 | // communication listener interface
|
---|
| 38 | virtual bool onLinkRequest(const NodeID& remote, Message* msg);
|
---|
| 39 | virtual void onMessage(Message* msg, const NodeID& remote, const LinkID& lnk);
|
---|
| 40 |
|
---|
| 41 | // node listener interface
|
---|
| 42 | virtual void onJoinCompleted( const SpoVNetID& vid );
|
---|
| 43 | virtual void onJoinFailed( const SpoVNetID& vid );
|
---|
| 44 |
|
---|
| 45 | // startup wrapper interface
|
---|
| 46 | virtual void startup();
|
---|
| 47 | virtual void shutdown();
|
---|
| 48 |
|
---|
| 49 | // timer events
|
---|
| 50 | virtual void eventFunction();
|
---|
| 51 |
|
---|
| 52 | private:
|
---|
| 53 | // the ariba module and a node
|
---|
| 54 | AribaModule* ariba;
|
---|
| 55 | Node* node;
|
---|
| 56 |
|
---|
| 57 | // flag, wheter this node is the initiator of this spovnet
|
---|
| 58 | bool isInitiator;
|
---|
| 59 |
|
---|
| 60 | // the ping pong service id
|
---|
| 61 | static ServiceID PINGPONG_ID;
|
---|
| 62 |
|
---|
| 63 | // the current ping id
|
---|
| 64 | unsigned long pingId;
|
---|
| 65 | };
|
---|
| 66 |
|
---|
| 67 | //ARIBA_SIMULATION_SERVICE(PingPong);
|
---|
| 68 |
|
---|
| 69 | }}} // namespace ariba, application, pingpong
|
---|
| 70 |
|
---|
| 71 | #endif // __PINGPONG_H_
|
---|