KanoopProtocolQt 1.2.3
Qt HTTP operations and MQTT client library
Loading...
Searching...
No Matches
KanoopProtocolQt

Qt library providing threaded HTTP operations and an auto-reconnecting MQTT client.

Modules

Module Description
HTTP Threaded GET, POST, PUT, DELETE, and multipart upload via QNetworkAccessManager
MQTT Auto-reconnecting MQTT 5.0 / 3.1.1 client with SSL/TLS support

Quick Start

HTTP GET

#include <Kanoop/http/httpget.h>
HttpGet get("https://api.example.com/data");
get.addParameter("page", "1");
connect(&get, &HttpOperation::operationComplete, [&]() {
qDebug() << get.statusCode() << get.responseBody();
});
get.start(); // runs in a dedicated thread
HTTP GET operation executed asynchronously on a dedicated thread.
Definition httpget.h:8
void operationComplete()
Emitted when the HTTP operation has completed.

HTTP POST (JSON)

#include <Kanoop/http/httppost.h>
QByteArray json = R"({"name":"test"})";
HttpPost post("https://api.example.com/items", json);
post.appendHeader(QNetworkRequest::ContentTypeHeader, "application/json");
connect(&post, &HttpOperation::operationComplete, [&]() {
qDebug() << post.statusCode();
});
post.start();
HTTP POST operation executed asynchronously on a dedicated thread.
Definition httppost.h:8

MQTT Client

#include <Kanoop/mqtt/mqttclient.h>
#include <Kanoop/mqtt/mqttparameters.h>
MqttParameters params("broker.example.com", 8883);
params.setUseSsl(true);
params.setUsername("device-001");
params.setPassword("token");
MqttClient client(params);
connect(&client, &MqttClient::clientConnected, [&]() {
client.subscribe("sensors/temperature");
client.publish("status/online", "1");
});
client.start();
MQTT client wrapper providing connection management, auto-reconnect, and SSL support.
Definition mqttclient.h:13
void clientConnected()
Emitted when the client connects to the broker.
Encapsulates connection parameters for an MQTT broker.

Building

cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x/gcc_64
cmake --build build --parallel

Requires KanoopCommonQt as a dependency.

Links