mqtt

package
v0.0.64 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPublishOption = PublishOption{
	QoS:     0,
	Retain:  false,
	Timeout: 5 * time.Second,
}
View Source
var DefaultSubscribeOption = SubscribeOption{
	QoS:     0,
	Timeout: 5 * time.Second,
}

Functions

func Client

func Client() (mqtt.Client, error)

Client returns the MQTT client instance

func Close added in v0.0.54

func Close() error

Close closes the MQTT client connection

func Health added in v0.0.54

func Health() error

Health checks if the MQTT client is connected

func Init

func Init() error

func Publish

func Publish(topic string, payload any, opts ...PublishOption) error

func Subscribe

func Subscribe(topic string, handler MessageHandler, opts ...SubscribeOption) error

func Unsubscribe added in v0.0.54

func Unsubscribe(topics ...string) error

Types

type MessageHandler added in v0.0.54

type MessageHandler func(topic string, payload []byte) error

type PublishOption added in v0.0.54

type PublishOption struct {
	QoS     byte
	Retain  bool
	Timeout time.Duration
}

type SubscribeOption added in v0.0.54

type SubscribeOption struct {
	QoS     byte
	Timeout time.Duration
}

Jump to

Keyboard shortcuts

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