mqttclient

package
v0.0.0-...-29e02a0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUBSCRIBE_STA_NOOK subscribeStaTp = 0
	SUBSCRIBE_STA_OK   subscribeStaTp = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConfigTp

type ClientConfigTp struct {
	Broker           string
	User             string
	Password         string
	Certificate      string // 证书文件
	PrivateKey       string // 秘钥
	ClientId         string
	WillEnabled      bool   // 遗愿
	WillTopic        string // 遗愿主题
	WillPayload      string // 遗愿消息
	WillQos          byte   // 遗愿服务质量
	Qos              byte   // 服务质量
	Retained         bool   // 保留消息
	OnConnect        MQTT.OnConnectHandler
	OnConnectionLost MQTT.ConnectionLostHandler
	KeepAlive        int
	ReconnectSec     int
}

type MqttClient

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

func NewMqttClient

func NewMqttClient(cfg ClientConfigTp) *MqttClient

func (*MqttClient) Close

func (a *MqttClient) Close()

func (*MqttClient) Connect

func (a *MqttClient) Connect()

func (*MqttClient) IsConnected

func (a *MqttClient) IsConnected() bool

func (*MqttClient) Publish

func (a *MqttClient) Publish(topic string, payload []byte) error

func (*MqttClient) Subscribe

func (a *MqttClient) Subscribe(topic string, handler SubscribeHandler) error

type SubscribeHandler

type SubscribeHandler func(topic string, payload []byte)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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