Changes between Version 18 and Version 19 of Documentation/Tutorial/PingPong


Ignore:
Timestamp:
Jan 22, 2009, 9:55:42 PM (16 years ago)
Author:
huebsch
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/Tutorial/PingPong

    v18 v19  
    125125}}}
    126126
    127 Tu shut a service down after its usage, every service provides a method ''shutdown'' which is automatically called upon finishing (lines 60-70). In here, we unbind the service, stop any timers (mentioned later) and finally leave leave or destroy the SpoVNet instance, depending on the specific node's role.
     127To shut a service down after its usage, every service provides a method ''shutdown'' which is automatically called upon finishing (lines 60-70). In here, we unbind the service, stop any timers (mentioned later) and finally leave leave or destroy the SpoVNet instance, depending on the specific node's role.
     128
     129
     130{{{
     13180 void PingPong::onNodeJoin( const NodeID& nodeid, const SpoVNetID& spovnetid ){
     13281
     13382      if( !startping ){
     13483             
     13584              logging_info( "establishing link to node " << nodeid.toString() );
     13685              const LinkID link = overlay->establishLink( nodeid, PingPong::PINGPONG_ID );
     13786
     13887              logging_info( "adding node to registered nodes in pingpong: " << nodeid.toString() );
     13988              remoteNodes.insert( make_pair(nodeid,link) );
     14089             
     14190              Timer::setInterval( 2000 );
     14291              Timer::start();
     14392      }
     14493 }
     145}}}
     146
     147''Ariba'' provides several callback functions that may used by services to catch all kinds of events that could be of interest. In this exampe we limit ourselves to the event cases of node joins and node leaves. When a node successfull joines to the SpoVNet instance, ''onNodeJoin'' is triggered nn the initiator's service side. He may then react to this event, exemplary shown in line 80-93, implementing ''onNodeJoin''. In this case, the initiator starts establishing a link to the joined node (line 85), essentially for all kinds of communications via ''Ariba''. We then store the link for further usage (line 88) and prepare a timer which intention is to trigger periodic events.
    128148
    129149
    130150
    131151
     152