mqtt_client

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: GPL-3.0 Imports: 8 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

ClientIdGen ...

Types

type Client

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

Client ...

func NewClient

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

NewClient ...

func (*Client) Connect

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

Connect ...

func (*Client) Disconnect

func (c *Client) Disconnect()

Disconnect ...

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected ...

func (*Client) Publish

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

Publish ...

func (*Client) Subscribe

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

Subscribe ...

func (*Client) Unsubscribe

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

Unsubscribe ...

func (*Client) UnsubscribeAll

func (c *Client) UnsubscribeAll()

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"`
}

Config ...

type Subscribe

type Subscribe struct {
	Qos      byte
	Callback MQTT.MessageHandler
}

Subscribe ...

Jump to

Keyboard shortcuts

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