Available
amalgame-mqtt
Pure MQTT 3.1.1 protocol, QoS 0.
Overview
MQTT 3.1.1 client that speaks the protocol directly over TCP, with no external library. It works with brokers that accept a connection without TLS or password: Mosquitto, HiveMQ, EMQX.
Features
- ✓Pure MQTT 3.1.1 protocol (CONNECT / SUBSCRIBE / PUBLISH / PINGREQ)
- ✓QoS 0 (fire-and-forget)
- ✓Wildcards
+and#in topics - ✓One message at a time:
WaitMessage, thenLastTopicandLastPayload
Planned for v2: QoS 1 and 2, retain, will, TLS, username and password.
Example
Minimal usage example — copy-paste runnable after install.
amc package add mqtt
import Amalgame.Messaging.MQTT
public class Program {
public static void Main(string[] args) {
let m = MQTT.Open("localhost", 1883, "client-42")
if (!MQTT.IsOpen(m)) {
Console.WriteLine("connect failed: " + MQTT.LastError(m))
return
}
MQTT.Subscribe(m, "sensors/+/temp")
MQTT.Publish(m, "sensors/room1/temp", "21.5")
if (MQTT.WaitMessage(m, 5000)) {
Console.WriteLine(MQTT.LastTopic(m) + " = " + MQTT.LastPayload(m))
}
MQTT.Close(m)
}
}
At a glance
- License: Apache-2.0
- Install:
amc package add mqtt - Source: amalgame-lang/amalgame-messaging-mqtt
- Official index: amalgame-lang/packages-index