mirror of
https://github.com/shirou/mqttcli.git
synced 2025-04-28 13:48:50 +08:00
add Disconnect on the end of publish. But not worked?
This commit is contained in:
parent
99d1c6d616
commit
efa2bb02c7
8
mqtt.go
8
mqtt.go
@ -48,6 +48,14 @@ func (m *MQTTClient) Publish(topic string, payload []byte, qos int, retain bool,
|
||||
return token.Error()
|
||||
}
|
||||
|
||||
func (m *MQTTClient) Disconnect() error {
|
||||
if m.Client.IsConnected() {
|
||||
m.Client.Disconnect(250)
|
||||
log.Info("client disconnected")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MQTTClient) SubscribeOnConnect(client *MQTT.Client) {
|
||||
log.Infof("client connected")
|
||||
|
||||
|
@ -53,4 +53,5 @@ func publish(c *cli.Context) {
|
||||
|
||||
}
|
||||
log.Info("Published")
|
||||
client.Disconnect()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user