mqtt: implement Close (#905)

* mqtt: implement Close

Signed-off-by: Long Dai <long0dai@foxmail.com>

* feedback

Signed-off-by: Long Dai <long0dai@foxmail.com>

Co-authored-by: Yaron Schneider <yaronsc@microsoft.com>
This commit is contained in:
Long Dai 2021-06-05 06:38:04 +08:00 committed by GitHub
parent 92846ab691
commit 01ca433ad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -311,3 +311,12 @@ func (m *MQTT) createClientOptions(uri *url.URL, clientID string) *mqtt.ClientOp
return opts
}
func (m *MQTT) Close() error {
if m.consumer != nil {
m.consumer.Disconnect(1)
}
m.producer.Disconnect(1)
return nil
}