Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/gha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: 11
platform: x64
- name: Cache boost
id: cache-boost
uses: actions/cache@v1
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/function2"]
path = external/function2
url = https://github.com/Naios/function2
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 14.0.0
* <<<< breaking change >>>> Replaced std::function with move_only_function. (#953)
* Removed old NetworkTS code. (#952)
* Fixed invalid timing async_shutdown handler call. (#950)
* Improved build system. (#948)

## 13.1.0
* Added clear username and password functionality. (#944)
* Refined utility tools. (#941, #942)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CMAKE_MINIMUM_REQUIRED (VERSION 3.13.0)
PROJECT (mqtt_cpp_iface VERSION 13.1.0)
PROJECT (mqtt_cpp_iface VERSION 14.0.0)

SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
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 13.1.0 [![Actions Status](https://github.com/redboltz/mqtt_cpp/workflows/CI/badge.svg)](https://github.com/redboltz/mqtt_cpp/actions)[![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 14.0.0 [![Actions Status](https://github.com/redboltz/mqtt_cpp/workflows/CI/badge.svg)](https://github.com/redboltz/mqtt_cpp/actions)[![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
12 changes: 3 additions & 9 deletions example/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ int main(int argc, char **argv) {
MQTT_NS::v5::properties /*props*/) {
if (pubopts.get_retain() == MQTT_NS::retain::yes) {
locked_cout() << "retained publish received and ignored topic:" << topic_name << std::endl;
return true;
return;
}
BOOST_ASSERT(rest_times > 0);
--rest_times;
Expand Down Expand Up @@ -742,8 +742,6 @@ int main(int argc, char **argv) {
--ci.recv_times;
if (rest_times == 0) finish_proc();
}

return true;
};

// ==== end local lambda expressions
Expand All @@ -764,7 +762,6 @@ int main(int argc, char **argv) {
else {
std::cout << "connack error:" << connack_return_code << std::endl;
}
return true;
}
);
ci.c->set_v5_connack_handler(
Expand All @@ -776,7 +773,6 @@ int main(int argc, char **argv) {
else {
std::cout << "connack error:" << reason_code << std::endl;
}
return true;
}
);

Expand All @@ -796,7 +792,6 @@ int main(int argc, char **argv) {
}
}
}
return true;
}
);
ci.c->set_v5_suback_handler(
Expand All @@ -817,7 +812,6 @@ int main(int argc, char **argv) {
}
}
}
return true;
}
);

Expand All @@ -827,7 +821,7 @@ int main(int argc, char **argv) {
MQTT_NS::publish_options pubopts,
MQTT_NS::buffer topic_name,
MQTT_NS::buffer contents) {
return publish_handler(ci, packet_id, pubopts, topic_name, contents, MQTT_NS::v5::properties{});
publish_handler(ci, packet_id, pubopts, topic_name, contents, MQTT_NS::v5::properties{});
}
);
ci.c->set_v5_publish_handler(
Expand All @@ -837,7 +831,7 @@ int main(int argc, char **argv) {
MQTT_NS::buffer topic_name,
MQTT_NS::buffer contents,
MQTT_NS::v5::properties props) {
return publish_handler(ci, packet_id, pubopts, topic_name, contents, MQTT_NS::force_move(props));
publish_handler(ci, packet_id, pubopts, topic_name, contents, MQTT_NS::force_move(props));
}
);
}
Expand Down
45 changes: 14 additions & 31 deletions example/client_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ int main(int argc, char* argv[]) {
std::cout << "< props:" << std::endl;
print_props("< ", props);
print_menu();
return true;
};

client.set_connack_handler(
Expand All @@ -615,7 +614,6 @@ int main(int argc, char* argv[]) {
}
);
}
return true;
}
);
client.set_v5_connack_handler(
Expand All @@ -641,7 +639,6 @@ int main(int argc, char* argv[]) {
}
);
}
return true;
}
);
client.set_publish_handler(
Expand All @@ -651,14 +648,13 @@ int main(int argc, char* argv[]) {
MQTT_NS::buffer topic_name,
MQTT_NS::buffer contents) {
std::cout << "< publish (v3.1.1)" << std::endl;
return
publish_handler(
packet_id,
pubopts,
topic_name,
contents,
MQTT_NS::v5::properties{}
);
publish_handler(
packet_id,
pubopts,
topic_name,
contents,
MQTT_NS::v5::properties{}
);
}
);
client.set_v5_publish_handler(
Expand All @@ -669,22 +665,20 @@ int main(int argc, char* argv[]) {
MQTT_NS::buffer contents,
MQTT_NS::v5::properties props) {
std::cout << "< publish (v5)" << std::endl;
return
publish_handler(
packet_id,
pubopts,
topic_name,
contents,
MQTT_NS::force_move(props)
);
publish_handler(
packet_id,
pubopts,
topic_name,
contents,
MQTT_NS::force_move(props)
);
}
);
client.set_puback_handler(
[&]
(packet_id_t packet_id){
std::cout << "< puback (v3.1.1)" << std::endl;
std::cout << "< packet_id:" << packet_id << std::endl;
return true;
}
);
client.set_v5_puback_handler( // use v5 handler
Expand All @@ -695,15 +689,13 @@ int main(int argc, char* argv[]) {
std::cout << "< reason_code:" << reason_code << std::endl;
std::cout << "< props:" << std::endl;
print_props("< ", props);
return true;
}
);
client.set_pubrec_handler(
[]
(packet_id_t packet_id){
std::cout << "< pubrec (v3.1.1)" << std::endl;
std::cout << "< packet_id:" << packet_id << std::endl;
return true;
}
);
client.set_v5_pubrec_handler( // use v5 handler
Expand All @@ -714,15 +706,13 @@ int main(int argc, char* argv[]) {
std::cout << "< reason_code:" << reason_code << std::endl;
std::cout << "< props:" << std::endl;
print_props("< ", props);
return true;
}
);
client.set_pubrel_handler(
[]
(packet_id_t packet_id){
std::cout << "< pubrel (v3.1.1)" << std::endl;
std::cout << "< packet_id:" << packet_id << std::endl;
return true;
}
);
client.set_v5_pubrel_handler( // use v5 handler
Expand All @@ -733,15 +723,13 @@ int main(int argc, char* argv[]) {
std::cout << "< reason_code:" << reason_code << std::endl;
std::cout << "< props:" << std::endl;
print_props("< ", props);
return true;
}
);
client.set_pubcomp_handler(
[&]
(packet_id_t packet_id){
std::cout << "< pubcomp (v3.1.1)" << std::endl;
std::cout << "< packet_id:" << packet_id << std::endl;
return true;
}
);
client.set_v5_pubcomp_handler( // use v5 handler
Expand All @@ -752,7 +740,6 @@ int main(int argc, char* argv[]) {
std::cout << "< reason_code:" << reason_code << std::endl;
std::cout << "< props:" << std::endl;
print_props("< ", props);
return true;
}
);
client.set_suback_handler(
Expand All @@ -765,7 +752,6 @@ int main(int argc, char* argv[]) {
std::cout << "< " << e << std::endl;
}
print_menu();
return true;
}
);
client.set_v5_suback_handler(
Expand All @@ -782,7 +768,6 @@ int main(int argc, char* argv[]) {
std::cout << "< props:" << std::endl;
print_props("< ", props);
print_menu();
return true;
}
);
client.set_unsuback_handler(
Expand All @@ -791,7 +776,6 @@ int main(int argc, char* argv[]) {
std::cout << "< unsuback (v3.1.1)" << std::endl;
std::cout << "< packet_id: " << packet_id << std::endl;
print_menu();
return true;
}
);
client.set_v5_unsuback_handler(
Expand All @@ -808,7 +792,6 @@ int main(int argc, char* argv[]) {
std::cout << "< props:" << std::endl;
print_props("< ", props);
print_menu();
return true;
}
);

Expand Down
14 changes: 0 additions & 14 deletions example/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void client_proc(
}
);
}
return true;
});
c->set_close_handler(
[]
Expand All @@ -64,20 +63,17 @@ void client_proc(
(packet_id_t packet_id){
locked_cout() << "[client] puback received. packet_id: " << packet_id << std::endl;
disconnect();
return true;
});
c->set_pubrec_handler(
[&]
(packet_id_t packet_id){
locked_cout() << "[client] pubrec received. packet_id: " << packet_id << std::endl;
return true;
});
c->set_pubcomp_handler(
[&]
(packet_id_t packet_id){
locked_cout() << "[client] pubcomp received. packet_id: " << packet_id << std::endl;
disconnect();
return true;
});
c->set_suback_handler(
[&]
Expand All @@ -93,7 +89,6 @@ void client_proc(
c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once);
c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once);
}
return true;
});
c->set_publish_handler(
[&]
Expand All @@ -110,7 +105,6 @@ void client_proc(
locked_cout() << "[client] topic_name: " << topic_name << std::endl;
locked_cout() << "[client] contents: " << contents << std::endl;
disconnect();
return true;
});

// Connect
Expand Down Expand Up @@ -225,7 +219,6 @@ void server_proc(Server& s, std::set<con_sp_t>& connections, mi_sub_con& subs) {
BOOST_ASSERT(sp);
connections.insert(sp);
sp->connack(false, MQTT_NS::connect_return_code::accepted);
return true;
}
);
ep.set_disconnect_handler(
Expand All @@ -240,25 +233,21 @@ void server_proc(Server& s, std::set<con_sp_t>& connections, mi_sub_con& subs) {
[]
(packet_id_t packet_id){
locked_cout() << "[server] puback received. packet_id: " << packet_id << std::endl;
return true;
});
ep.set_pubrec_handler(
[]
(packet_id_t packet_id){
locked_cout() << "[server] pubrec received. packet_id: " << packet_id << std::endl;
return true;
});
ep.set_pubrel_handler(
[]
(packet_id_t packet_id){
locked_cout() << "[server] pubrel received. packet_id: " << packet_id << std::endl;
return true;
});
ep.set_pubcomp_handler(
[]
(packet_id_t packet_id){
locked_cout() << "[server] pubcomp received. packet_id: " << packet_id << std::endl;
return true;
});
ep.set_publish_handler(
[&subs]
Expand All @@ -283,7 +272,6 @@ void server_proc(Server& s, std::set<con_sp_t>& connections, mi_sub_con& subs) {
std::min(r.first->qos_value, pubopts.get_qos())
);
}
return true;
});
ep.set_subscribe_handler(
[&subs, wp]
Expand All @@ -300,7 +288,6 @@ void server_proc(Server& s, std::set<con_sp_t>& connections, mi_sub_con& subs) {
subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos());
}
sp->suback(packet_id, res);
return true;
}
);
ep.set_unsubscribe_handler(
Expand All @@ -314,7 +301,6 @@ void server_proc(Server& s, std::set<con_sp_t>& connections, mi_sub_con& subs) {
auto sp = wp.lock();
BOOST_ASSERT(sp);
sp->unsuback(packet_id);
return true;
}
);
}
Expand Down
Loading