Documentation ¶
Overview ¶
* @Description : * @Date : 2020-04-16 11:35:43 * @LastEditors : Hu * @LastEditTime : 2021-07-04 11:58:40 * @FilePath : \gomqtt\publisher.go
* @Description : * @Date : 2020-04-16 11:35:43 * @LastEditors : Hu * @LastEditTime : 2021-07-04 11:52:25 * @FilePath : \gomqtt\status_changed.go
* @Description : * @Date : 2020-04-16 11:35:43 * @LastEditors : Hu * @LastEditTime : 2021-07-04 11:50:45 * @FilePath : \gomqtt\subscriber.go
Index ¶
- func GetClient(opts *mqtt.ClientOptions) (client mqtt.Client, err error)
- func GetClientOptions(conf *Config) *mqtt.ClientOptions
- func Init(opts *mqtt.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 ¶
Types ¶
type Config ¶
type Config struct { Broker string // Broker地址,例如tcp://127.0.0.1:1883或ssl://127.0.0.1:8883. 如果配置ssl,则必须配置CACert Username string // 用户名,可选 Password string // 密码,可选 CACert string // CA证书,单向认证只需要配置此文件即可,无需ClientCert和ClientKey,可选 ClientCert string // ClientCert,可选 ClientKey string // ClientKey,可选 ClientID string // ClientID,可选 }
MQTT的配置信息格式
type SubscribeType ¶
type SubscribeType struct { Topic string Qos byte Callback mqtt.MessageHandler RetryTimes int // 为0表示无限重试 }
Click to show internal directories.
Click to hide internal directories.