Skip to content

Commit

Permalink
Merge pull request #383 from redboltz/fix_382
Browse files Browse the repository at this point in the history
Fixed #382.
  • Loading branch information
redboltz authored Sep 3, 2019
2 parents ed3cd91 + 8c83313 commit c66f3db
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 30 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 6.0.3
* Fixed sync subscribe/unsubscribe with properties APIs dispatch to deprecated APIs problem. (#383)

## 6.0.2
* Fixed moved from object access problem. (#378)
* Fixed unexpected copy fallback of move operations. (#378)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MQTT client/server for C++14 based on Boost.Asio

Version 6.0.2 [![Build Status](https://travis-ci.org/redboltz/mqtt_cpp.svg?branch=master)](https://travis-ci.org/redboltz/mqtt_cpp)[![Build Status](https://dev.azure.com/redboltz/redboltz/_apis/build/status/redboltz.mqtt_cpp?branchName=master)](https://dev.azure.com/redboltz/redboltz/_build/latest?definitionId=6&branchName=master)[![codecov](https://codecov.io/gh/redboltz/mqtt_cpp/branch/master/graph/badge.svg)](https://codecov.io/gh/redboltz/mqtt_cpp)
Version 6.0.3 [![Build Status](https://travis-ci.org/redboltz/mqtt_cpp.svg?branch=master)](https://travis-ci.org/redboltz/mqtt_cpp)[![Build Status](https://dev.azure.com/redboltz/redboltz/_apis/build/status/redboltz.mqtt_cpp?branchName=master)](https://dev.azure.com/redboltz/redboltz/_build/latest?definitionId=6&branchName=master)[![codecov](https://codecov.io/gh/redboltz/mqtt_cpp/branch/master/graph/badge.svg)](https://codecov.io/gh/redboltz/mqtt_cpp)

Important note https://github.com/redboltz/mqtt_cpp/wiki/News.

Expand Down
141 changes: 112 additions & 29 deletions include/mqtt/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1804,17 +1804,22 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* subscription options<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169<BR>
* 3.8.3.1 Subscription Options
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901164<BR>
* 3.8.2.1 SUBSCRIBE Properties
* @return packet_id.
* packet_id is automatically generated.<BR>
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901161
*/
template <typename... Args>
packet_id_t subscribe(
string_view topic_name,
std::uint8_t option) {
std::uint8_t option,
std::vector<v5::property_variant> props = {}
) {
packet_id_t packet_id = acquire_unique_packet_id();
acquired_subscribe(packet_id, topic_name, option);
acquired_subscribe(packet_id, topic_name, option, force_move(props));
return packet_id;
}

Expand Down Expand Up @@ -1855,16 +1860,22 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* subscription options<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169<BR>
* 3.8.3.1 Subscription Options
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901164<BR>
* 3.8.2.1 SUBSCRIBE Properties
* @return packet_id.
* packet_id is automatically generated.<BR>
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901161
*/
packet_id_t subscribe(
as::const_buffer topic_name,
std::uint8_t option) {
std::uint8_t option,
std::vector<v5::property_variant> props = {}
) {
packet_id_t packet_id = acquire_unique_packet_id();
acquired_subscribe(packet_id, topic_name, option);
acquired_subscribe(packet_id, topic_name, option, force_move(props));
return packet_id;
}

Expand Down Expand Up @@ -1905,16 +1916,22 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* subscription options<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169<BR>
* 3.8.3.1 Subscription Options
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901164<BR>
* 3.8.2.1 SUBSCRIBE Properties
* @return packet_id.
* packet_id is automatically generated.<BR>
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901161
*/
packet_id_t subscribe(
buffer topic_name,
std::uint8_t option) {
std::uint8_t option,
std::vector<v5::property_variant> props = {}
) {
packet_id_t packet_id = acquire_unique_packet_id();
acquired_subscribe(packet_id, force_move(topic_name), option);
acquired_subscribe(packet_id, force_move(topic_name), option, force_move(props));
return packet_id;
}

Expand Down Expand Up @@ -1997,14 +2014,20 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* @brief Unsubscribe
* @param topic_name
* A topic name to unsubscribe
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901182<BR>
* 3.10.2.1 UNSUBSCRIBE Properties
* @return packet_id.
* packet_id is automatically generated.<BR>
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901179
*/
packet_id_t unsubscribe(
string_view topic_name) {
return unsubscribe(as::buffer(topic_name.data(), topic_name.size()));
string_view topic_name,
std::vector<v5::property_variant> props = {}
) {
return unsubscribe(as::buffer(topic_name.data(), topic_name.size()), force_move(props));
}

/**
Expand Down Expand Up @@ -2033,15 +2056,21 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* @brief Unsubscribe
* @param topic_name
* A topic name to unsubscribe
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901182<BR>
* 3.10.2.1 UNSUBSCRIBE Properties
* @return packet_id.
* packet_id is automatically generated.<BR>
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901179
*/
packet_id_t unsubscribe(
as::const_buffer topic_name) {
as::const_buffer topic_name,
std::vector<v5::property_variant> props = {}
) {
packet_id_t packet_id = acquire_unique_packet_id();
acquired_unsubscribe(packet_id, topic_name);
acquired_unsubscribe(packet_id, topic_name, force_move(props));
return packet_id;
}

Expand Down Expand Up @@ -2073,15 +2102,21 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* @brief Unsubscribe
* @param topic_name
* A topic name to unsubscribe
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901182<BR>
* 3.10.2.1 UNSUBSCRIBE Properties
* @return packet_id.
* packet_id is automatically generated.<BR>
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901179
*/
packet_id_t unsubscribe(
buffer topic_name) {
buffer topic_name,
std::vector<v5::property_variant> props = {}
) {
packet_id_t packet_id = acquire_unique_packet_id();
acquired_unsubscribe(packet_id, force_move(topic_name));
acquired_unsubscribe(packet_id, force_move(topic_name), force_move(props));
return packet_id;
}

Expand Down Expand Up @@ -2581,6 +2616,10 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* subscription options<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169<BR>
* 3.8.3.1 Subscription Options
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901164<BR>
* 3.8.2.1 SUBSCRIBE Properties
* @return If packet_id is used in the publishing/subscribing sequence, then returns false and
* doesn't subscribe, otherwise return true and subscribes.
* You can subscribe multiple topics all at once.<BR>
Expand All @@ -2589,9 +2628,11 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
bool subscribe(
packet_id_t packet_id,
string_view topic_name,
std::uint8_t option) {
std::uint8_t option,
std::vector<v5::property_variant> props = {}
) {
if (register_packet_id(packet_id)) {
acquired_subscribe(packet_id, topic_name, option);
acquired_subscribe(packet_id, topic_name, option, force_move(props));
return true;
}
return false;
Expand All @@ -2607,6 +2648,10 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* subscription options<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169<BR>
* 3.8.3.1 Subscription Options
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901164<BR>
* 3.8.2.1 SUBSCRIBE Properties
* @return If packet_id is used in the publishing/subscribing sequence, then returns false and
* doesn't subscribe, otherwise return true and subscribes.
* You can subscribe multiple topics all at once.<BR>
Expand All @@ -2615,9 +2660,11 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
bool subscribe(
packet_id_t packet_id,
as::const_buffer topic_name,
std::uint8_t option) {
std::uint8_t option,
std::vector<v5::property_variant> props = {}
) {
if (register_packet_id(packet_id)) {
acquired_subscribe(packet_id, topic_name, option);
acquired_subscribe(packet_id, topic_name, option, force_move(props));
return true;
}
return false;
Expand Down Expand Up @@ -2740,16 +2787,22 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* packet identifier
* @param topic_name
* A topic name to unsubscribe
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901182<BR>
* 3.10.2.1 UNSUBSCRIBE Properties
* @return If packet_id is used in the publishing/subscribing sequence, then returns false and
* doesn't unsubscribe, otherwise return true and unsubscribes.
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901179
*/
bool unsubscribe(
packet_id_t packet_id,
string_view topic_name) {
string_view topic_name,
std::vector<v5::property_variant> props = {}
) {
if (register_packet_id(packet_id)) {
acquired_unsubscribe(packet_id, topic_name);
acquired_unsubscribe(packet_id, topic_name, force_move(props));
return true;
}
return false;
Expand All @@ -2761,16 +2814,22 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* packet identifier
* @param topic_name
* A topic name to unsubscribe
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901182<BR>
* 3.10.2.1 UNSUBSCRIBE Properties
* @return If packet_id is used in the publishing/subscribing sequence, then returns false and
* doesn't unsubscribe, otherwise return true and unsubscribes.
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901179
*/
bool unsubscribe(
packet_id_t packet_id,
as::const_buffer topic_name) {
as::const_buffer topic_name,
std::vector<v5::property_variant> props = {}
) {
if (register_packet_id(packet_id)) {
acquired_unsubscribe(packet_id, topic_name);
acquired_unsubscribe(packet_id, topic_name, force_move(props));
return true;
}
return false;
Expand Down Expand Up @@ -3430,15 +3489,21 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* subscription options<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169<BR>
* 3.8.3.1 Subscription Options
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901164<BR>
* 3.8.2.1 SUBSCRIBE Properties
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901161<BR>
*/
void acquired_subscribe(
packet_id_t packet_id,
string_view topic_name,
std::uint8_t option) {
std::uint8_t option,
std::vector<v5::property_variant> props = {}
) {
std::vector<std::tuple<buffer, std::uint8_t>> params;
send_subscribe(force_move(params), packet_id, topic_name, option);
send_subscribe(force_move(params), packet_id, topic_name, option, force_move(props));
}

/**
Expand All @@ -3452,15 +3517,21 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* subscription options<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169<BR>
* 3.8.3.1 Subscription Options
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901164<BR>
* 3.8.2.1 SUBSCRIBE Properties
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901161<BR>
*/
void acquired_subscribe(
packet_id_t packet_id,
as::const_buffer topic_name,
std::uint8_t option) {
std::uint8_t option,
std::vector<v5::property_variant> props = {}
) {
std::vector<std::tuple<buffer, std::uint8_t>> params;
send_subscribe(force_move(params), packet_id, topic_name, option);
send_subscribe(force_move(params), packet_id, topic_name, option, force_move(props));
}

/**
Expand Down Expand Up @@ -3541,16 +3612,22 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* The ownership of the packet_id moves to the library.
* @param topic_name
* A topic name to unsubscribe
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901182<BR>
* 3.10.2.1 UNSUBSCRIBE Properties
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901179
*/
void acquired_unsubscribe(
packet_id_t packet_id,
string_view topic_name) {
string_view topic_name,
std::vector<v5::property_variant> props = {}
) {

std::vector<buffer> params;

send_unsubscribe(force_move(params), packet_id, topic_name);
send_unsubscribe(force_move(params), packet_id, topic_name, force_move(props));
}

/**
Expand All @@ -3560,16 +3637,22 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
* The ownership of the packet_id moves to the library.
* @param topic_name
* A topic name to unsubscribe
* @param props
* Properties<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901182<BR>
* 3.10.2.1 UNSUBSCRIBE Properties
* You can subscribe multiple topics all at once.<BR>
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901179
*/
void acquired_unsubscribe(
packet_id_t packet_id,
as::const_buffer topic_name) {
as::const_buffer topic_name,
std::vector<v5::property_variant> props = {}
) {

std::vector<buffer> params;

send_unsubscribe(force_move(params), packet_id, topic_name);
send_unsubscribe(force_move(params), packet_id, topic_name, force_move(props));
}

/**
Expand Down

0 comments on commit c66f3db

Please sign in to comment.