Documentation ¶
Index ¶
- func Create(config *ClientConfig, handler func(*paho.Publish), ...) (err error)
- func DefaultConnectionManager() **autopaho.ConnectionManager
- type ClientBuild
- func (build *ClientBuild) AddServerURL(url ...string) *ClientBuild
- func (build *ClientBuild) AddSubscribe(subscribe ...string) *ClientBuild
- func (build *ClientBuild) BuildAndConnection() (connectionManager *autopaho.ConnectionManager, err error)
- func (build *ClientBuild) SetClientError(clientError ClientError) *ClientBuild
- func (build *ClientBuild) SetClientID(clientID string) *ClientBuild
- func (build *ClientBuild) SetConnectionError(connectionError ConnectionError) *ClientBuild
- func (build *ClientBuild) SetConnectionSuccess(connectionSuccess ConnectionSuccess) *ClientBuild
- func (build *ClientBuild) SetMessageCallback(m paho.MessageHandler) *ClientBuild
- func (build *ClientBuild) SetServerDisconnect(serverDisconnect ServerDisconnect) *ClientBuild
- func (build *ClientBuild) SetUsernamePassword(un, pwd string) *ClientBuild
- type ClientConfig
- type ClientError
- type ConnectionError
- type ConnectionSuccess
- type ServerDisconnect
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(config *ClientConfig, handler func(*paho.Publish), connectionManager **autopaho.ConnectionManager) (err error)
Create 创建 mqtt 的 autopaho.ConnectionManager,
config 是 mqtt 的配置
handler 是 mqtt 收到消息的回调
connectionManager 是 mqtt 的连接实例, 通过这个二级指针返回新的 mqtt 连接实例, 还会关闭旧的连接实例。
func DefaultConnectionManager ¶
func DefaultConnectionManager() **autopaho.ConnectionManager
DefaultConnectionManager 获取空的 MQTT 连接
Types ¶
type ClientBuild ¶
type ClientBuild struct { ClientConfig MessageCallback paho.MessageHandler ConnectionSuccess ConnectionSuccess ConnectionError ConnectionError ClientError ClientError ServerDisconnect ServerDisconnect }
func NewClientBuild ¶
func NewClientBuild() *ClientBuild
func (*ClientBuild) AddServerURL ¶
func (build *ClientBuild) AddServerURL(url ...string) *ClientBuild
AddServerURL 添加服务器
func (*ClientBuild) AddSubscribe ¶
func (build *ClientBuild) AddSubscribe(subscribe ...string) *ClientBuild
AddSubscribe 添加订阅
func (*ClientBuild) BuildAndConnection ¶
func (build *ClientBuild) BuildAndConnection() (connectionManager *autopaho.ConnectionManager, err error)
func (*ClientBuild) SetClientError ¶
func (build *ClientBuild) SetClientError(clientError ClientError) *ClientBuild
SetClientError 其它原因导致客户端连接断开
func (*ClientBuild) SetClientID ¶
func (build *ClientBuild) SetClientID(clientID string) *ClientBuild
SetClientID 设置客户端ID
func (*ClientBuild) SetConnectionError ¶
func (build *ClientBuild) SetConnectionError(connectionError ConnectionError) *ClientBuild
SetConnectionError 连接 MQTT 服务端失败
func (*ClientBuild) SetConnectionSuccess ¶
func (build *ClientBuild) SetConnectionSuccess(connectionSuccess ConnectionSuccess) *ClientBuild
SetConnectionSuccess 成功连接到 MQTT 服务端
func (*ClientBuild) SetMessageCallback ¶
func (build *ClientBuild) SetMessageCallback(m paho.MessageHandler) *ClientBuild
SetMessageCallback 设置消息回调
func (*ClientBuild) SetServerDisconnect ¶
func (build *ClientBuild) SetServerDisconnect(serverDisconnect ServerDisconnect) *ClientBuild
SetServerDisconnect 收到服务端的断开连接命令
func (*ClientBuild) SetUsernamePassword ¶
func (build *ClientBuild) SetUsernamePassword(un, pwd string) *ClientBuild
SetUsernamePassword 设置用户名和密码
type ClientConfig ¶
type ClientError ¶
type ClientError func(err error)
type ConnectionError ¶
type ConnectionError func(err error)
type ConnectionSuccess ¶
type ConnectionSuccess func(*autopaho.ConnectionManager, *paho.Connack)
type ServerDisconnect ¶
type ServerDisconnect func(*paho.Disconnect)
Click to show internal directories.
Click to hide internal directories.