mqtx

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeMessage

func DecodeMessage(payload []byte) (*map[string]interface{}, error)

func Init

func Init()

func RegisterMQTT

func RegisterMQTT(aliasName string, conf *Config)

Types

type Client

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

func MQ

func MQ(name ...string) *Client

func (*Client) Connect

func (c *Client) Connect() error

连接

func (*Client) GetClientID

func (c *Client) GetClientID() string

func (*Client) Publish

func (c *Client) Publish(topic string, data interface{}, qos QoS) error

发布消息,topic主题,data发送数据,qos发送等级

func (*Client) Subscribe

func (c *Client) Subscribe(qos QoS, observer func(c *Client, payload []byte), topics ...string) error

订阅

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(topics ...string)

取消订阅

type Config

type Config struct {
	Name     string `mapstructure:"name"`
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`
	ClientID string `mapstructure:"client_id"`
}

type QoS

type QoS int32
const (
	QoS0 QoS = 0 // 最多一次
	QoS1 QoS = 1 // 至少一次
	QoS2 QoS = 2 // 只有一次
)

Jump to

Keyboard shortcuts

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