Changes between Version 29 and Version 30 of Documentation/Tutorial/PingPong


Ignore:
Timestamp:
Apr 28, 2009, 4:14:04 PM (15 years ago)
Author:
huebsch
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/Tutorial/PingPong

    v29 v30  
    137137After definitions for construction und destruction (the first also setting a timer to 5 seconds), we come to the ''startup'' method.
    138138The ''startup'' method (lines 20 ff.) is called from the !StartupWrapper, jolting the operation of the ping pong service. Here, we first create an AribaModule object, serving as our port to ''Ariba'' (line 33). Then, we give our network instance a specific name (being ''spovnet'' in the example), before we collect some configurational parameters (lines 46-56). Those parameters are defined in the config file, they serve e.g. in giving IP adresses and port numbers to ariba instances. In line 56, we start ''Ariba''. Also, we need a ''Node'' object, reflecting our application running over ''Ariba'' (more than one could possibly be using one Ariba). This is created in line 62 and the bound to the ariba object with its specific ServiceID. After this bnind operation, the ''Node'' is able to receive signals and messages from ''Ariba''. After this, we start the node object and either initiate or join the network instance (depending on the role of the actual node, wich could be initiator or joiner).
    139 Finally, we may give out all kinds of logging infos by calling the method logging_info (line 47).
     139Finally, we may give out all kinds of logging infos by calling the method logging_info (line 76).
    140140 
    141141
    142142{{{
    143 60 void PingPong::shutdown(){
    144 61      logging_info( "shutting down PingPong service ..." );
    145 62
    146 63      overlay->unbind( this, PingPong::PINGPONG_ID );
    147 64      Timer::stop();
    148 65
    149 66      if( !startping ) abstraction->destroySpoVNet( context );
    150 67      else             abstraction->leaveSpoVNet( context );
    151 68
    152 69      logging_info( "PingPong service shut down" );
    153 70 }
    154 }}}
    155 
    156 To 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.
    157 
     14301 void PingPong::shutdown() {
     14402
     14503      logging_info( "pingpong service starting shutdown sequence ..." );
     14604
     14705      // stop timer
     14806      Timer::stop();
     14907
     15008      // leave spovnet
     15109      node->leave();
     15210
     15311      // unbind communication and node listener
     15412      node->unbind( this );                               /*NodeListener*/
     15513      node->unbind( this, PingPong::PINGPONG_SERVICEID ); /*CommunicationListener*/
     15614
     15715      // stop the ariba module
     15816      ariba->stop();
     15917
     16018      // delete node and ariba module
     16119      delete node;
     16220      delete ariba;
     16321
     16422      // now we are completely shut down
     16523      logging_info( "pingpong service shut down" );
     16624}
     167}}}
     168
     169To shut a service down after its usage, every service provides a method ''shutdown'' which is automatically called upon finishing. In here, we stop the timer, leave the instance, unbind all bindings and finally stop the node and ''Ariba''. Don't forget to delete yopur objects to prevent from memory leaks.
    158170
    159171{{{