Documentation
¶
Index ¶
- func GetPid() int
- type Client
- func (c *Client) Connect(address string) error
- func (c *Client) Consume()
- func (c *Client) Disconnect() error
- func (c *Client) HandConnack(fn func())
- func (c *Client) HandPuback(fn func())
- func (c *Client) HandPubcomp(fn func(pid []byte))
- func (c *Client) HandPublish(fn func(msg *MqttMsg))
- func (c *Client) HandPubrec(fn func(pid []byte))
- func (c *Client) HandPubrel(fn func(pid []byte))
- func (c *Client) HandSuback(fn func())
- func (c *Client) Publish(msg *MqttMsg) error
- func (c *Client) Subscribe(topic string, pid int, qos int) error
- func (c *Client) Unsubscribe(topic string, pid int) error
- func (c *Client) Write(d []byte) error
- type MqttMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
ID string // the Client Identifier, cannot be nil, and should be unique
Keepalive int // idle time, when timeout, disconnect from server
WillRetain bool // "will retain" flag, it must be false unless "WillFlag == true"
WillQos int // "will qos" flag, it must be zero unless "WillFlag == frue"
WillFlag bool // "will flag"
CleanSession bool
WillTopic string
WillWorlds string
UserName string
PassWorld string
sync.Mutex
// contains filtered or unexported fields
}
func NewMqttClient ¶
func NewMqttClient() *Client
func (*Client) Disconnect ¶
func (*Client) HandConnack ¶
func (c *Client) HandConnack(fn func())
Will be callback when mqtt client connect to broker success
func (*Client) HandPuback ¶
func (c *Client) HandPuback(fn func())
A PUBACK Packet is the response to a PUBLISH Packet with QoS level 1.
func (*Client) HandPubcomp ¶
The PUBCOMP Packet is the response to a PUBREL Packet. It is the fourth and final packet of the QoS 2 protocol exchange.
func (*Client) HandPublish ¶
Will be callback when mqtt msg publish success
func (*Client) HandPubrec ¶
A PUBREC Packet is the response to a PUBLISH Packet with QoS 2. It is the second packet of the QoS 2 protocol exchange.
func (*Client) HandPubrel ¶
A PUBREL Packet is the response to a PUBREC Packet. It is the third packet of the QoS 2 protocol exchange.
func (*Client) HandSuback ¶
func (c *Client) HandSuback(fn func())
Will be callback when subscribe topic success
func (*Client) Publish ¶
for more detail of parames, see "http://blog.mcxiaoke.com/mqtt/protocol/MQTT-3.1.1-CN.html#pfc" or "http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html"