mirror of
https://github.com/eclipse-paho/paho.mqtt.cpp.git
synced 2025-09-15 12:58:39 +08:00
#547 Fixed up some of the v5 examples for proper connect options
Some checks are pending
CMake on multiple platforms / build (Debug, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Debug, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Debug, gcc, g++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Waiting to run
Some checks are pending
CMake on multiple platforms / build (Debug, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Debug, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Debug, gcc, g++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Waiting to run
This commit is contained in:
parent
6a1c354df4
commit
8ef1a1e73b
@ -43,7 +43,6 @@ using namespace std;
|
|||||||
const string DFLT_SERVER_URI{"mqtt://localhost:1883"};
|
const string DFLT_SERVER_URI{"mqtt://localhost:1883"};
|
||||||
const string CLIENT_ID{"PahoCppAsyncConsumeV5"};
|
const string CLIENT_ID{"PahoCppAsyncConsumeV5"};
|
||||||
|
|
||||||
// const string TOPIC{"hello"};
|
|
||||||
const string TOPIC{"#"};
|
const string TOPIC{"#"};
|
||||||
const int QOS = 1;
|
const int QOS = 1;
|
||||||
|
|
||||||
|
|||||||
@ -193,9 +193,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
mqtt::async_client cli(serverURI, CLIENT_ID);
|
mqtt::async_client cli(serverURI, CLIENT_ID);
|
||||||
|
|
||||||
auto connOpts = mqtt::connect_options_builder::v5()
|
auto connOpts = mqtt::connect_options_builder::v5().clean_start(true).finalize();
|
||||||
.clean_start(true)
|
|
||||||
.finalize();
|
|
||||||
|
|
||||||
// Install the callback(s) before connecting.
|
// Install the callback(s) before connecting.
|
||||||
callback cb(cli, connOpts);
|
callback cb(cli, connOpts);
|
||||||
|
|||||||
@ -76,7 +76,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// Set up the connect options
|
// Set up the connect options
|
||||||
|
|
||||||
auto connOpts = mqtt::connect_options_builder()
|
auto connOpts = mqtt::connect_options_builder::v5()
|
||||||
.properties({{mqtt::property::SESSION_EXPIRY_INTERVAL, 604800}})
|
.properties({{mqtt::property::SESSION_EXPIRY_INTERVAL, 604800}})
|
||||||
.clean_start(false)
|
.clean_start(false)
|
||||||
.will(std::move(lwt))
|
.will(std::move(lwt))
|
||||||
|
|||||||
@ -90,10 +90,9 @@ double mult(const std::vector<double>& nums)
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
mqtt::create_options createOpts(MQTTVERSION_5);
|
mqtt::client cli(SERVER_ADDRESS, CLIENT_ID);
|
||||||
mqtt::client cli(SERVER_ADDRESS, CLIENT_ID, createOpts);
|
|
||||||
|
|
||||||
auto connOpts = mqtt::connect_options_builder()
|
auto connOpts = mqtt::connect_options_builder::v5()
|
||||||
.keep_alive_interval(seconds(20))
|
.keep_alive_interval(seconds(20))
|
||||||
.clean_start()
|
.clean_start()
|
||||||
.finalize();
|
.finalize();
|
||||||
|
|||||||
@ -84,7 +84,7 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
auto serverURI = (argc > 1) ? std::string{argv[1]} : DFLT_SERVER_URI;
|
auto serverURI = (argc > 1) ? std::string{argv[1]} : DFLT_SERVER_URI;
|
||||||
|
|
||||||
mqtt::client cli(serverURI, CLIENT_ID, mqtt::create_options(MQTTVERSION_5));
|
mqtt::client cli(serverURI, CLIENT_ID);
|
||||||
|
|
||||||
auto connOpts = mqtt::connect_options_builder::v5()
|
auto connOpts = mqtt::connect_options_builder::v5()
|
||||||
.automatic_reconnect(seconds(2), seconds(30))
|
.automatic_reconnect(seconds(2), seconds(30))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user