CoreMQTTSimple

package
v5.2.20 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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) Publish

func (t *MQTTSimple) Publish(topic string, qos byte, retained bool, data []byte) (token mqtt.Token)

Publish 推送一个新的任务 异步进行

func (*MQTTSimple) PublishWait

func (t *MQTTSimple) PublishWait(topic string, qos byte, retained bool, data []byte) (err error)

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 去掉订阅

Jump to

Keyboard shortcuts

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