Changes between Version 23 and Version 24 of Documentation/Tutorial/PingPong


Ignore:
Timestamp:
Jan 22, 2009, 10:22:30 PM (15 years ago)
Author:
huebsch
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/Tutorial/PingPong

    v23 v24  
    178178}}}
    179179
    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.
     180Everytime 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.
    181181
    182182{{{
     
    209209}}}
    210210
    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 
     211Lines 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{{{
     214130 bool PingPong::receiveMessage(const Message* message, const LinkID& link, const NodeID& node){
     215131     
     216132     PingPongMessage* incoming = ((Message*)message)->decapsulate<PingPongMessage>();
     217133     
     218134     logging_info( "received ping message on link " << link.toString() <<
     219135                              " from node with id " << (int)incoming->getid());
     220136
     221137 }
     222}}}
     223
     224Getting 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).