Disponible
amalgame-mqtt
MQTT 3.1.1 protocole pur, QoS 0.
Vue d'ensemble
Client MQTT 3.1.1 qui parle le protocole directement sur TCP, sans bibliothèque externe. Il fonctionne avec les brokers qui acceptent une connexion sans TLS ni mot de passe : Mosquitto, HiveMQ, EMQX.
Caractéristiques
- ✓Protocole MQTT 3.1.1 pur (CONNECT / SUBSCRIBE / PUBLISH / PINGREQ)
- ✓QoS 0 (fire-and-forget)
- ✓Wildcard
+et#dans les topics - ✓Un message à la fois :
WaitMessage, puisLastTopicetLastPayload
Prévu en v2 : QoS 1 et 2, retain, will, TLS, identifiant et mot de passe.
Exemple
Exemple minimal d'utilisation — recopiable tel quel après l'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)
}
}
En bref
- Licence : Apache-2.0
- Installation :
amc package add mqtt - Code source : amalgame-lang/amalgame-messaging-mqtt
- Index officiel : amalgame-lang/packages-index