Skip to content

Commit

Permalink
Fixed connect with listener
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagliughi committed Jul 6, 2024
1 parent 03dfef9 commit 5357a28
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/async_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,19 +413,14 @@ token_ptr async_client::connect(connect_options opts)

token_ptr async_client::connect(connect_options opts, void* userContext, iaction_listener& cb)
{
// If the options specified a new MQTT protocol version, we should
// use it, otherwise default to the version requested when the client
// was created.
if (opts.opts_.MQTTVersion == 0 && mqttVersion_ >= 5)
opts.opts_.MQTTVersion = mqttVersion_;
else
mqttVersion_ = opts.opts_.MQTTVersion;
// Remember the requested protocol version
mqttVersion_ = opts.opts_.MQTTVersion;

// The C lib is very picky about version and clean start/session
if (opts.opts_.MQTTVersion >= 5)
opts.opts_.cleansession = 0;
else
if (opts.opts_.MQTTVersion < 5)
opts.opts_.cleanstart = 0;
else
opts.opts_.cleansession = 0;

auto tmpTok = connTok_;
connTok_ = token::create(token::Type::CONNECT, *this, userContext, cb);
Expand Down

0 comments on commit 5357a28

Please sign in to comment.