Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMQTTv311Client ¶
func NewMQTTv311Client(cfg *MqttConfig) (*mqttv311Client, error)
func NewMQTTv5Client ¶
func NewMQTTv5Client(cfg *MqttConfig) (*mqttv5Client, error)
Types ¶
type Client ¶
type Client interface {
Connect() (bool, error)
Publish(topic string, data []byte) error
SubscribeMultiple(filters map[string]byte, callback paho.MessageHandler) error
AddRoute(topic string, callback paho.MessageHandler)
Close() error
}
Client is a protocol neutral MQTT client for connecting, disconnecting, and publishing data to a topic. The protocol specific clients must implement this interface
func NewClient ¶
func NewClient(cfg *MqttConfig) (Client, error)
type MqttConfig ¶
type MqttConfig struct {
Servers []string `toml:"servers"`
Protocol string `toml:"protocol"`
Username config.Secret `toml:"username"`
Password config.Secret `toml:"password"`
Timeout config.Duration `toml:"timeout"`
ConnectionTimeout config.Duration `toml:"connection_timeout"`
QoS int `toml:"qos"`
ClientID string `toml:"client_id"`
Retain bool `toml:"retain"`
KeepAlive int64 `toml:"keep_alive"`
PersistentSession bool `toml:"persistent_session"`
PublishPropertiesV5 *PublishProperties `toml:"v5"`
ClientTrace bool `toml:"client_trace" deprecated:"1.37.0;1.45.0;use 'log_level' 'trace' instead"`
tls.ClientConfig
AutoReconnect bool `toml:"-"`
OnConnectionLost func(error) `toml:"-"`
}
type PublishProperties ¶
type PublishProperties struct {
ContentType string `toml:"content_type"`
ResponseTopic string `toml:"response_topic"`
MessageExpiry config.Duration `toml:"message_expiry"`
TopicAlias *uint16 `toml:"topic_alias"`
UserProperties map[string]string `toml:"user_properties"`
}
PublishProperties for mqtt v5-specific properties. See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901109
Click to show internal directories.
Click to hide internal directories.