From c666943583f6da5f459804790b1e2ac9aa34ba36 Mon Sep 17 00:00:00 2001 From: Peter M. Groen Date: Sat, 12 Feb 2022 15:31:39 +0100 Subject: [PATCH] Added multiple topics to the test. --- examples/pub/main.cpp | 18 +++++++++++------- examples/sub/main.cpp | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/pub/main.cpp b/examples/pub/main.cpp index 9c181de..edb970f 100644 --- a/examples/pub/main.cpp +++ b/examples/pub/main.cpp @@ -83,14 +83,18 @@ int main( int argc, char* argv[] ) // Assume we are connected now, start publishing. while( 1 ) { - std::string payload = "" ; - pPublisher->publish( std::string( "test/publisher/TestPublisher" ), payload ); - + for( unsigned int nCount = 0; nCount < 10; nCount++ ) + { + std::string payload = "" ; + pPublisher->publish( std::string( "test/publisher/TestPublisher_" + std::to_string( nCount ) ), payload ); + + if( messageNumber > 2000000000 ) + { + messageNumber = -1; + } + messageNumber++; + } sleepcp( 1, T_MICRO ); - if( messageNumber > 2000000000 ) - messageNumber = -1; - - messageNumber++; } } else diff --git a/examples/sub/main.cpp b/examples/sub/main.cpp index 57e365c..0699e74 100644 --- a/examples/sub/main.cpp +++ b/examples/sub/main.cpp @@ -78,12 +78,12 @@ int main( int argc, char* argv[] ) std::cout << "Connecting to the test-broker : " << std::endl; pSubscriber->connect( "office.osdev.nl", 1883, "", "" ); std::cout << "Subscribing to the test-topic....." << std::endl; - pSubscriber->subscribe( "test/publisher/TestPublisher" ); + pSubscriber->subscribe( "test/publisher/#" ); // Start a loop to give the subscriber the possibility to do its work. while( 1 ) { - sleepcp( 1, T_SECONDS ); // Sleep 1 Sec to give the scheduler the change to interfene. + sleepcp( 1, T_MICRO ); // Sleep 1 Sec to give the scheduler the change to interfene. } } else -- libgit2 0.21.4