Commit c666943583f6da5f459804790b1e2ac9aa34ba36

Authored by Peter M. Groen
1 parent f45c31d8

Added multiple topics to the test.

examples/pub/main.cpp
... ... @@ -83,14 +83,18 @@ int main( int argc, char* argv[] )
83 83 // Assume we are connected now, start publishing.
84 84 while( 1 )
85 85 {
86   - std::string payload = "<Timestamp value=\"" + std::to_string( getEpochUSecs() ) + "\" /><MessageNumber value=\"" + std::to_string( messageNumber ) + "\" />" ;
87   - pPublisher->publish( std::string( "test/publisher/TestPublisher" ), payload );
88   -
  86 + for( unsigned int nCount = 0; nCount < 10; nCount++ )
  87 + {
  88 + std::string payload = "<Timestamp value=\"" + std::to_string( getEpochUSecs() ) + "\" /><MessageNumber value=\"" + std::to_string( messageNumber ) + "\" />" ;
  89 + pPublisher->publish( std::string( "test/publisher/TestPublisher_" + std::to_string( nCount ) ), payload );
  90 +
  91 + if( messageNumber > 2000000000 )
  92 + {
  93 + messageNumber = -1;
  94 + }
  95 + messageNumber++;
  96 + }
89 97 sleepcp( 1, T_MICRO );
90   - if( messageNumber > 2000000000 )
91   - messageNumber = -1;
92   -
93   - messageNumber++;
94 98 }
95 99 }
96 100 else
... ...
examples/sub/main.cpp
... ... @@ -78,12 +78,12 @@ int main( int argc, char* argv[] )
78 78 std::cout << "Connecting to the test-broker : " << std::endl;
79 79 pSubscriber->connect( "office.osdev.nl", 1883, "", "" );
80 80 std::cout << "Subscribing to the test-topic....." << std::endl;
81   - pSubscriber->subscribe( "test/publisher/TestPublisher" );
  81 + pSubscriber->subscribe( "test/publisher/#" );
82 82  
83 83 // Start a loop to give the subscriber the possibility to do its work.
84 84 while( 1 )
85 85 {
86   - sleepcp( 1, T_SECONDS ); // Sleep 1 Sec to give the scheduler the change to interfene.
  86 + sleepcp( 1, T_MICRO ); // Sleep 1 Sec to give the scheduler the change to interfene.
87 87 }
88 88 }
89 89 else
... ...