mqtt_client

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIdGen added in v0.1.0

func ClientIdGen(args ...interface{}) string

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg *Config) (client *Client, err error)

func (*Client) Connect

func (c *Client) Connect() (err error)

func (*Client) Disconnect

func (c *Client) Disconnect()

func (*Client) IsConnected

func (c *Client) IsConnected() bool

func (*Client) Publish

func (c *Client) Publish(topic string, payload interface{}) (err error)

func (*Client) Subscribe

func (c *Client) Subscribe(topic string, qos byte, callback MQTT.MessageHandler) (err error)

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(topic string) (err error)

func (*Client) UnsubscribeAll

func (c *Client) UnsubscribeAll()

type Config

type Config struct {
	KeepAlive      int    `json:"keep_alive"`
	PingTimeout    int    `json:"ping_timeout"`
	Broker         string `json:"broker"`
	ClientID       string `json:"client_id"`
	ConnectTimeout int    `json:"connect_timeout"`
	CleanSession   bool   `json:"clean_session"`
	Username       string `json:"username"`
	Password       string `json:"password"`
	Qos            byte   `json:"qos"`
}

type Subscribe

type Subscribe struct {
	Qos      byte
	Callback MQTT.MessageHandler
}

Jump to

Keyboard shortcuts

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