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. |
| 127 | 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. |
| 128 | |
| 129 | |
| 130 | {{{ |
| 131 | 80 void PingPong::onNodeJoin( const NodeID& nodeid, const SpoVNetID& spovnetid ){ |
| 132 | 81 |
| 133 | 82 if( !startping ){ |
| 134 | 83 |
| 135 | 84 logging_info( "establishing link to node " << nodeid.toString() ); |
| 136 | 85 const LinkID link = overlay->establishLink( nodeid, PingPong::PINGPONG_ID ); |
| 137 | 86 |
| 138 | 87 logging_info( "adding node to registered nodes in pingpong: " << nodeid.toString() ); |
| 139 | 88 remoteNodes.insert( make_pair(nodeid,link) ); |
| 140 | 89 |
| 141 | 90 Timer::setInterval( 2000 ); |
| 142 | 91 Timer::start(); |
| 143 | 92 } |
| 144 | 93 } |
| 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. |