Documentation
¶
Index ¶
- func GetClient(opts *gomqtt.ClientOptions) (client gomqtt.Client, err error)
- func GetClientOptions(conf *Config) *gomqtt.ClientOptions
- func Init(opts *gomqtt.ClientOptions) (err error)
- func Publish(topic string, payload interface{}, qos byte, retained bool) (err error)
- func Subscribe(item SubscribeType)
- type Config
- type SubscribeType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetClient ¶
func GetClient(opts *gomqtt.ClientOptions) (client gomqtt.Client, err error)
获取MQTT连接
Types ¶
type Config ¶
type Config struct { Broker string // Broker地址,例如tcp://127.0.0.1:1883或ssl://127.0.0.1:8883. 如果配置ssl,则必须配置CAFile Username string // 用户名,可选 Password string // 密码,可选 CAFile string //证书,单向认证只需要配置此文件即可,无需CertFile和KeyFile,可选 CertFile string // 客户端Cert,可选 KeyFile string // 客户端Key,可选 ClientID string // ClientID,可选 }
MQTT的配置信息格式
type SubscribeType ¶
type SubscribeType struct { Topic string Qos byte Callback gomqtt.MessageHandler RetryTimes int // 为0表示无限重试 }
Click to show internal directories.
Click to hide internal directories.