Changes between Version 23 and Version 24 of Documentation/Tutorial/PingPong
- Timestamp:
- Jan 22, 2009, 10:22:30 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Documentation/Tutorial/PingPong
v23 v24 178 178 }}} 179 179 180 Everytime the timer 'fires', ''eventFunction'' is called on a node (lines 110-125). In this example, the initiator sends a message to every node that has joined up to this point in time. To accomplish this, it iterates through all established links (line 119), builts a message for every link and finally sends the message using the Base Overlay in ''Ariba'' . We will now take a short look at how such a message is composed in the ping pong example.180 Everytime the timer 'fires', ''eventFunction'' is called on a node (lines 110-125). In this example, the initiator sends a message to every node that has joined up to this point in time. To accomplish this, it iterates through all established links (line 119), builts a message for every link and finally sends the message using the Base Overlay in ''Ariba'' (line 123). Sending messages is done by passing the message object to ''Ariba'', together with the target link to use. . We will now take a short look at how such a message is composed in the ping pong example. 181 181 182 182 {{{ … … 209 209 }}} 210 210 211 Lines 01-26 show the whole !PingPongMessage.cpp. One can see here that defining message types in Ariba is pretty simple. As the message in our case is empty and not of higher importantance, we refer the reader to the documentation for details. 212 211 Lines 01-26 show the whole !PingPongMessage.cpp. One can see here that defining message types in Ariba is pretty simple. As the message in our case is empty and not of higher importance, we refer the reader to the documentation for details. 212 213 {{{ 214 130 bool PingPong::receiveMessage(const Message* message, const LinkID& link, const NodeID& node){ 215 131 216 132 PingPongMessage* incoming = ((Message*)message)->decapsulate<PingPongMessage>(); 217 133 218 134 logging_info( "received ping message on link " << link.toString() << 219 135 " from node with id " << (int)incoming->getid()); 220 136 221 137 } 222 }}} 223 224 Getting back to ''!PingPong.cpp'': After the initiator has send a message to a joiner, it will arrive and has to be handled. This is accomplished in ''receiveMessage'' (the name says it). Every received message has to be decapsulated by a service, casting the data back to the service's message format (line 132).