From 3158a0a132d6af4de78c9be90e45834350cfd414 Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 27 Mar 2026 14:39:33 +0100 Subject: Add server version publishing This makes it possible that the client adapts it's behaviour easily to the server version making support of breaking API changes during early development and debugging easier. --- mqtt.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mqtt.go') diff --git a/mqtt.go b/mqtt.go index acd0108..26b6444 100644 --- a/mqtt.go +++ b/mqtt.go @@ -46,6 +46,7 @@ func (m MQTTMessage) String() string { func MQTTRun(config MQTTConfig, tx chan MQTTMessage, routes ...Route) { mqttServerHealthTopic = fmt.Sprintf("%s/server/health", config.TopicPrefix) + mqttServerVersionTopic := fmt.Sprintf("%s/server/version", config.TopicPrefix) opts := mqtt.NewClientOptions() opts.AddBroker(config.Broker) @@ -54,6 +55,7 @@ func MQTTRun(config MQTTConfig, tx chan MQTTMessage, routes ...Route) { opts.SetOnConnectHandler(func(c mqtt.Client) { log.Printf("Connected to MQTT broker.") c.Publish(mqttServerHealthTopic, QoS1, true, []byte(`good`)) + c.Publish(mqttServerVersionTopic, QoS1, true, []byte(Version())) for _, route := range routes { topic := config.TopicPrefix + "/" + route.Topic -- cgit v1.3