Changeset 2483 for sample/pingpong/PingPong.cpp
- Timestamp:
- Feb 24, 2009, 10:06:43 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sample/pingpong/PingPong.cpp
r2473 r2483 17 17 // construction 18 18 PingPong::PingPong() : pingId( 0 ) { 19 Timer::setInterval( 5000 ); 19 20 } 20 21 … … 70 71 71 72 // bind communication and node listener 72 node->bind( this);73 node->bind( this, PingPong::PINGPONG_ID);73 node->bind( this ); 74 node->bind( this, PingPong::PINGPONG_ID); 74 75 76 // start the ping timer. if we are not 77 // the initiator this will happen in onJoinCompleted 78 if( isInitiator ) Timer::start(); 79 75 80 // ping pong started up... 76 81 logging_info( "pingpong started up "); … … 85 90 Timer::stop(); 86 91 87 // unbind listeners92 // unbind communication and node listener 88 93 node->unbind( this ); 89 94 node->unbind( this, PingPong::PINGPONG_ID ); … … 108 113 109 114 // start the timer to ping every second 110 Timer::setInterval( 1000 );111 115 Timer::start(); 112 116 } … … 117 121 118 122 // communication listener 119 bool PingPong::onLinkRequest(const NodeID& remote, Message*msg) {123 bool PingPong::onLinkRequest(const NodeID& remote, const DataMessage& msg) { 120 124 return false; 121 125 } 122 126 123 void PingPong::onMessage(Message* msg, const NodeID& remote, 124 const LinkID& lnk = LinkID::UNSPECIFIED) { 127 void PingPong::onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk) { 125 128 126 PingPongMessage* pingmsg = msg ->decapsulate<PingPongMessage> ();129 PingPongMessage* pingmsg = msg.getMessage()->decapsulate<PingPongMessage> (); 127 130 128 131 logging_info( "received ping message on link " << lnk.toString() 129 132 << " from node " << remote.toString() 130 << ": " << pingmsg-> toString() );133 << ": " << pingmsg->info() ); 131 134 } 132 135 … … 142 145 PingPongMessage pingmsg( pingId ); 143 146 node->sendBroadcastMessage( pingmsg, PingPong::PINGPONG_ID ); 144 145 147 } 146 148
Note:
See TracChangeset
for help on using the changeset viewer.