49 | | Now we look into the ''PingPong.cpp'', containing the actual ping pong code. We leave out .h files here because they only do definitions. Everyone intending to use ''Ariba'' should be familiar with the subject matter. |
| 49 | Now we look into the ''PingPong.cpp'', containing the actual ping pong code. We leave out .h files here because they only do definitions. Everyone intending to use ''Ariba'' should be familiar with the subject matter. The first parts look like this: |
| 50 | |
| 51 | {{{ |
| 52 | 01 #include "PingPong.h" |
| 53 | 02 |
| 54 | 03 namespace ariba { |
| 55 | 04 namespace application { |
| 56 | 05 namespace pingpong { |
| 57 | 06 |
| 58 | 07 use_logging_cpp(PingPong); |
| 59 | 08 ServiceID PingPong::PINGPONG_ID = ServiceID(111); |
| 60 | 09 |
| 61 | 10 PingPong::PingPong() : pingid( 0 ) { |
| 62 | 11 } |
| 63 | 12 |
| 64 | 13 PingPong::~PingPong(){ |
| 65 | 14 } |
| 66 | 15 |
| 67 | 16 void PingPong::setMode(bool startingNode){ |
| 68 | 17 startping = startingNode; |
| 69 | 18 } |
| 70 | 19 |
| 71 | 20 void PingPong::startup(UnderlayAbstraction* _abstraction){ |
| 72 | 21 abstraction = _abstraction; |
| 73 | 22 |
| 74 | 23 logging_info( "starting up PingPong service ... " ); |
| 75 | 24 |
| 76 | 25 SpoVNetID spovnetid (Identifier(5000)); |
| 77 | 26 |
| 78 | 27 NodeID nodeid = (Configuration::instance().exists("BASE_nodeid") ? |
| 79 | 28 NodeID(Identifier(Configuration::instance().read<unsigned long>("BASE_nodeid"))) : |
| 80 | 29 NodeID::UNSPECIFIED); |
| 81 | 30 |
| 82 | 31 IPv4Locator* locallocator = (Configuration::instance().exists("BASE_localLocator") ? |
| 83 | 32 &(IPv4Locator::fromString(Configuration::instance().read<string>("BASE_localLocator"))) : |
| 84 | 33 NULL); |
| 85 | 34 |
| 86 | 35 uint16_t localport = Configuration::instance().exists("BASE_port") ? |
| 87 | 36 Configuration::instance().read<uint16_t>("BASE_port") : |
| 88 | 37 ARIBA_DEFAULT_PORT; |
| 89 | 38 |
| 90 | 39 if( !startping ) |
| 91 | 40 context = abstraction->createSpoVNet( spovnetid, nodeid, locallocator, localport ); |
| 92 | 41 else |
| 93 | 42 context = abstraction->joinSpoVNet ( spovnetid, nodeid, locallocator, localport ); |
| 94 | 43 |
| 95 | 44 overlay = &context->getOverlay(); |
| 96 | 45 overlay->bind( this, PingPong::PINGPONG_ID ); |
| 97 | 46 |
| 98 | 47 logging_info( "PingPong started up" ); |
| 99 | 48 |
| 100 | 49 // trigger the creation of the pathload measurement module |
| 101 | 50 //PathloadMeasurement::instance( overlay ); |
| 102 | 51 } |
| 103 | }}} |