mqtt

package module
v0.0.0-...-5fbe5b0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: MIT Imports: 2 Imported by: 0

README

mqtt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClientOptions

func GetClientOptions(conf *Config) *gomqtt.ClientOptions

获取MQTT连接配置项

Types

type Client

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

MQTT连接

func (*Client) Init

func (m *Client) Init(opts *gomqtt.ClientOptions) (err error)

初始化监听器

func (Client) Publish

func (m Client) Publish(topic string, payload interface{}, qos byte, retained bool) (err error)

通用发布消息接口

func (*Client) Subscribe

func (m *Client) Subscribe(item SubscribeType)

注册订阅消息

type Config

type Config struct {
	Broker   string `json:"Broker"`   // Broker地址,例如tcp://127.0.0.1:1883
	ClientID string `json:"ClientID"` // ClientID
}

MQTT的配置信息格式

type SubscribeType

type SubscribeType struct {
	Topic      string
	Qos        byte
	Callback   gomqtt.MessageHandler
	RetryTimes int // 为0表示无限重试
}

Jump to

Keyboard shortcuts

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