mqtt

package
v0.27.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2024 License: LGPL-2.1 Imports: 5 Imported by: 0

Documentation

Overview

Package mqtt provides a bit of glue common between Skogul's MQTT sender and receiver. Mostly providing mechanisms for setting up and maintaining a connection to a broker. You really should not include this directly. Use the MQTT sender and receiver instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MQTT

type MQTT struct {
	Client        mqtt.Client
	RenewClientID bool
	MQTTLogs      bool
	// contains filtered or unexported fields
}

MQTT contains an MQTT client, its options and its configuration for handling messages

func (*MQTT) Connect

func (handler *MQTT) Connect() error

Connect to the broker and subscribe to the relevant topics, if any.

func (*MQTT) Init

func (handler *MQTT) Init(address, username, password, clientID string) error

Init sets up the MQTT client

func (*MQTT) Subscribe

func (handler *MQTT) Subscribe(topic string, callback MessageHandler)

Subscribe to a topic. callback is called whenever a message is received. This also deals with re-subscribing when a reconnect takes place.

type MessageHandler

type MessageHandler func(Message mqtt.Message)

MessageHandler is used to establish a callback when a message is received.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL