mirror of
				https://github.com/brianshea2/meshmap.net.git
				synced 2025-03-05 21:00:01 -08:00 
			
		
		
		
	remove unnecessary unsubscribe before disconnect
This commit is contained in:
		
							parent
							
								
									f33853a4dd
								
							
						
					
					
						commit
						77509cb40e
					
				|  | @ -36,7 +36,6 @@ type MQTTClient struct { | ||||||
| 	Accept         func(from uint32) bool | 	Accept         func(from uint32) bool | ||||||
| 	BlockCipher    cipher.Block | 	BlockCipher    cipher.Block | ||||||
| 	MessageHandler func(from uint32, topic string, portNum generated.PortNum, payload []byte) | 	MessageHandler func(from uint32, topic string, portNum generated.PortNum, payload []byte) | ||||||
| 	topics         []string |  | ||||||
| 	mqtt.Client | 	mqtt.Client | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -68,16 +67,12 @@ func (c *MQTTClient) Connect() error { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
| 		log.Printf("[info] subscribed to %v", topic) | 		log.Printf("[info] subscribed to %v", topic) | ||||||
| 		c.topics = append(c.topics, topic) |  | ||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c *MQTTClient) Disconnect() { | func (c *MQTTClient) Disconnect() { | ||||||
| 	if c.IsConnected() { | 	if c.IsConnected() { | ||||||
| 		if c.Unsubscribe(c.topics...).WaitTimeout(time.Second) { |  | ||||||
| 			log.Print("[info] unsubscribed") |  | ||||||
| 		} |  | ||||||
| 		c.Client.Disconnect(1000) | 		c.Client.Disconnect(1000) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue