Documentation ¶
Index ¶
- type MQTTSimple
- func (t *MQTTSimple) ConnectClient() (err error)
- func (t *MQTTSimple) ConnectServer(options *mqtt.ClientOptions) (token mqtt.Token)
- func (t *MQTTSimple) GetByIDOptions(id string)
- func (t *MQTTSimple) Init(tServerURL, tUsername, tPassword, prefix string) (err error)
- func (t *MQTTSimple) Publish(topic string, qos byte, retained bool, data []byte) (token mqtt.Token)
- func (t *MQTTSimple) PublishWait(topic string, qos byte, retained bool, data []byte) (err error)
- func (t *MQTTSimple) SetDefaultClientID(tDefaultClientID string)
- func (t *MQTTSimple) SetServer(tServerURL, tUsername, tPassword string)
- func (t *MQTTSimple) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) (token mqtt.Token)
- func (t *MQTTSimple) SubscribeCancel(topic string) (token mqtt.Token)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MQTTSimple ¶
type MQTTSimple struct { //全局client连接 Client mqtt.Client //是否启动info追踪 OpenInfoLog bool //选项扩展 Options *mqtt.ClientOptions //必须断开重连 NeedDisConnectOnIsConnect bool // contains filtered or unexported fields }
func (*MQTTSimple) ConnectClient ¶
func (t *MQTTSimple) ConnectClient() (err error)
ConnectClient 链接到服务
func (*MQTTSimple) ConnectServer ¶
func (t *MQTTSimple) ConnectServer(options *mqtt.ClientOptions) (token mqtt.Token)
ConnectServer 连接到服务
func (*MQTTSimple) GetByIDOptions ¶
func (t *MQTTSimple) GetByIDOptions(id string)
GetByIDOptions 构建带有id的选项
func (*MQTTSimple) Init ¶
func (t *MQTTSimple) Init(tServerURL, tUsername, tPassword, prefix string) (err error)
Init 初始化基本设计 本方法不会连接服务,需手动触发后续连接处理机制
func (*MQTTSimple) PublishWait ¶
PublishWait 推送一个新的任务
func (*MQTTSimple) SetDefaultClientID ¶
func (t *MQTTSimple) SetDefaultClientID(tDefaultClientID string)
SetDefaultClientID 设置默认特征指纹
func (*MQTTSimple) SetServer ¶
func (t *MQTTSimple) SetServer(tServerURL, tUsername, tPassword string)
SetServer 设置服务器信息
func (*MQTTSimple) Subscribe ¶
func (t *MQTTSimple) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) (token mqtt.Token)
Subscribe 订阅消息
func (*MQTTSimple) SubscribeCancel ¶
func (t *MQTTSimple) SubscribeCancel(topic string) (token mqtt.Token)
SubscribeCancel 去掉订阅
Click to show internal directories.
Click to hide internal directories.