1
0
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:
Shirou WAKAYAMA 2015-03-25 13:07:46 +09:00
parent 99d1c6d616
commit efa2bb02c7
2 changed files with 9 additions and 0 deletions

View File

@ -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")

View File

@ -53,4 +53,5 @@ func publish(c *cli.Context) {
}
log.Info("Published")
client.Disconnect()
}