1
0
mirror of https://github.com/shirou/mqttcli.git synced 2025-04-28 13:48:50 +08:00

not subscribe if publish or subscribe not set.

This commit is contained in:
Shirou WAKAYAMA 2015-04-03 18:31:24 +09:00
parent c4ca530d38
commit 5da1819b94

View File

@ -59,12 +59,14 @@ func (m *MQTTClient) Disconnect() error {
func (m *MQTTClient) SubscribeOnConnect(client *MQTT.Client) {
log.Infof("client connected")
if len(m.Subscribed) > 0 {
token := client.SubscribeMultiple(m.Subscribed, m.onMessageReceived)
token.Wait()
if token.Error() != nil {
log.Error(token.Error())
}
}
}
func (m *MQTTClient) ConnectionLost(client *MQTT.Client, reason error) {
log.Errorf("client disconnected: %s", reason)