00001 #ifndef __PINGPONG_H_ 00002 #define __PINGPONG_H_ 00003 00004 #include "ariba/ariba.h" 00005 #include "PingPongMessage.h" 00006 #include "ariba/utility/system/StartupInterface.h" 00007 #include "ariba/utility/system/Timer.h" 00008 00009 #include <vector> 00010 00011 using namespace ariba; 00012 using ariba::utility::StartupInterface; 00013 using ariba::utility::Timer; 00014 00015 namespace ariba { 00016 namespace application { 00017 namespace pingpong { 00018 00019 using namespace std; 00020 00027 class PingPong: public NodeListener, 00028 public CommunicationListener, 00029 public StartupInterface, 00030 public Timer { 00031 00032 use_logging_h(PingPong); 00033 00034 public: 00035 PingPong(); 00036 virtual ~PingPong(); 00037 00038 protected: 00039 // communication listener interface 00040 virtual bool onLinkRequest(const NodeID& remote); 00041 virtual void onMessage(const DataMessage& msg, const NodeID& remote, 00042 const LinkID& lnk = LinkID::UNSPECIFIED); 00043 virtual void onLinkUp(const LinkID& lnk, const NodeID& remote); 00044 virtual void onLinkDown(const LinkID& lnk, const NodeID& remote); 00045 virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote); 00046 virtual void onLinkFail(const LinkID& lnk, const NodeID& remote); 00047 00048 // node listener interface 00049 virtual void onJoinCompleted(const SpoVNetID& vid); 00050 virtual void onJoinFailed(const SpoVNetID& vid); 00051 virtual void onLeaveCompleted(const SpoVNetID& vid); 00052 virtual void onLeaveFailed(const SpoVNetID& vid); 00053 00054 // startup wrapper interface 00055 virtual void startup(); 00056 virtual void shutdown(); 00057 00058 // timer events 00059 virtual void eventFunction(); 00060 00061 private: 00062 // the ariba module and a node 00063 AribaModule* ariba; 00064 Node* node; 00065 string name; 00066 int counter; 00067 vector<string> names; 00068 00069 // the ping pong service id 00070 static ServiceID PINGPONG_SERVICEID; 00071 00072 // the current ping id 00073 unsigned long pingId; 00074 00075 }; 00076 00077 // needed for simulation support 00078 ARIBA_SIMULATION_SERVICE(PingPong); 00079 00080 }}} // namespace ariba, application, pingpong 00081 00082 #endif // __PINGPONG_H_