Compare commits
	
		
			2 Commits
		
	
	
		
			27f0d7ab06
			...
			6374562137
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 6374562137 | |||
| edb18eebe0 | 
@@ -22,6 +22,7 @@ func NewClient(logger *zap.Logger, config *config.Config, csvHelper *csv.Helper)
 | 
				
			|||||||
		switch n := notification.(type) {
 | 
							switch n := notification.(type) {
 | 
				
			||||||
		case mqtt.ConnectionNotificationConnected:
 | 
							case mqtt.ConnectionNotificationConnected:
 | 
				
			||||||
			logger.Info("Connected to MQTT broker")
 | 
								logger.Info("Connected to MQTT broker")
 | 
				
			||||||
 | 
								StartListening(logger, config, client)
 | 
				
			||||||
		case mqtt.ConnectionNotificationConnecting:
 | 
							case mqtt.ConnectionNotificationConnecting:
 | 
				
			||||||
			logger.Info("connecting", zap.Bool("isReconnect", n.IsReconnect), zap.Int("attempt", n.Attempt))
 | 
								logger.Info("connecting", zap.Bool("isReconnect", n.IsReconnect), zap.Int("attempt", n.Attempt))
 | 
				
			||||||
		case mqtt.ConnectionNotificationFailed:
 | 
							case mqtt.ConnectionNotificationFailed:
 | 
				
			||||||
@@ -49,6 +50,7 @@ func NewClient(logger *zap.Logger, config *config.Config, csvHelper *csv.Helper)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func StartListening(logger *zap.Logger, config *config.Config, client mqtt.Client) {
 | 
					func StartListening(logger *zap.Logger, config *config.Config, client mqtt.Client) {
 | 
				
			||||||
 | 
						logger.Info("Subscribing to", zap.Int("topics", len(config.Topics)))
 | 
				
			||||||
	for _, topic := range config.Topics {
 | 
						for _, topic := range config.Topics {
 | 
				
			||||||
		if token := client.Subscribe(topic, 0, nil); token.Wait() && token.Error() != nil {
 | 
							if token := client.Subscribe(topic, 0, nil); token.Wait() && token.Error() != nil {
 | 
				
			||||||
			logger.Error("error subscribing to topic", zap.String("topic", topic), zap.Error(token.Error()))
 | 
								logger.Error("error subscribing to topic", zap.String("topic", topic), zap.Error(token.Error()))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user