mqtt_manager

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message interface {
	mqtt.Message
	GetUid() (string, error)
	GetDeviceStatus() (domain.DeviceStatus, error)
	GetPayloadBool() (bool, error)
}

func NewMessage

func NewMessage(msg mqtt.Message, parser Parser) (Message, error)

type MessageHandler

type MessageHandler interface {
	MessageHandle(client mqtt.Client, msg mqtt.Message)
}

func NewMessageHandlerAdapter

func NewMessageHandlerAdapter(h func(mqtt.Client, Message), parser Parser) MessageHandler

type MessageHandlerAdapter

type MessageHandlerAdapter struct {
	// contains filtered or unexported fields
}

func (*MessageHandlerAdapter) MessageHandle

func (adapter *MessageHandlerAdapter) MessageHandle(client mqtt.Client, msg mqtt.Message)

type MqttManager

type MqttManager struct {
	// contains filtered or unexported fields
}

func NewMqttManager

func NewMqttManager(brokerURL, clientId, username, password string) *MqttManager

func (*MqttManager) Connect

func (m *MqttManager) Connect() error

func (*MqttManager) Disconnect

func (m *MqttManager) Disconnect(timeout uint)

func (*MqttManager) IsConnected

func (m *MqttManager) IsConnected() bool

func (*MqttManager) Publish

func (m *MqttManager) Publish(topic string, payload interface{}) error

func (*MqttManager) SetTopicHandle

func (m *MqttManager) SetTopicHandle(topic string, h MessageHandler)

type Parser

type Parser interface {
	ParseUid(topic string) (string, error)
}

func NewDefaultTopicParser

func NewDefaultTopicParser() Parser

type PayloadConversionError

type PayloadConversionError struct {
	Payload string
}

func (*PayloadConversionError) Error

func (e *PayloadConversionError) Error() string

type TopicFormatError

type TopicFormatError struct {
	Topic string
}

func (*TopicFormatError) Error

func (e *TopicFormatError) Error() string

type ValidationError

type ValidationError struct {
	Message string
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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