vibe-mqtt 1.1.0
A MQTT broker client for D
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
vibe-mqtt
MQTT broker client library written completely in D.
MQTT protocol version supported: 3.1.1
Depends on: vibe.d
Tested on:
Supported MQTT 3.1.1 features:
- [x] QoS0, QoS1 and QoS2 messages handling
- [x] Authentication
- [x] Session state storage (currently in memory only - #20)
- [x] Sending retain messages
- [x] Async API (publish blocks if send queue is full)
- [x] Data agnostic
- [x] Message ordering
- [x] KeepAlive mechanism support (PingReq/PingResp) (#11)
- [x] Auto reconnect to broker (#15)
- [x] TLS/SSL (#16)
- [ ] On subscribe topics validation (#17)
- [ ] Last Will and Testament (LWT) (#21)
- [ ] Delivery retry (#14)
Pull Requests are welcome, don't be shy ;)
Usage
Example code can be found in the examples
directory.
Publisher
Simple publisher which connects to the MQTT broker and periodically sends a message. Implicitly it connects to 127.0.0.1:1883
auto settings = Settings();
settings.clientId = "test publisher";
auto mqtt = new MqttClient(settings);
mqtt.connect();
auto publisher = runTask(() {
while (mqtt.connected) {
mqtt.publish("chat", "I'm still here!!!");
sleep(2.seconds());
}
});
Subscriber
Simple subscriber which connects to the MQTT broker, subscribes to the topic and outputs each received message. Implicitly it connects to 127.0.0.1:1883
auto settings = Settings();
settings.clientId = "test subscriber";
settings.onConnAck = (scope MqttClient ctx, in ConnAck packet)
{
ctx.subscribe(["chat"]);
};
settings.onPublish = (scope MqttClient ctx, in Publish packet)
{
writeln("chat: ", cast(string)packet.payload);
};
auto mqtt = new MqttClient(settings);
mqtt.connect();
- 1.1.0 released 2 months ago
- tchaloupka/vibe-mqtt
- BSL-1.0
- Copyright © 2019, Tomáš Chaloupka
- Authors:
- Dependencies:
- vibe-d:utils, vibe-d:tls, vibe-d:stream
- Versions:
-
1.1.0 2024-Oct-11 1.0.1 2024-Oct-11 1.0.0 2023-Jun-13 1.0.0-alpha.3 2023-Apr-27 1.0.0-alpha.2 2022-Sep-19 - Download Stats:
-
-
10 downloads today
-
20 downloads this week
-
137 downloads this month
-
17230 downloads total
-
- Score:
- 3.2
- Short URL:
- vibe-mqtt.dub.pm