aboutsummaryrefslogtreecommitdiff
path: root/catbus.go
diff options
context:
space:
mode:
authorEthel Morgan <eth@ethulhu.co.uk>2020-06-30 15:38:57 +0100
committerEthel Morgan <eth@ethulhu.co.uk>2020-06-30 15:38:57 +0100
commit5d0003e5a36359afa21d6509de330b9fa2e81d70 (patch)
tree80bd548eaa9938a20f33d89d50bdc1523ba325f2 /catbus.go
parente3be5b2a39a1e2b04adc1468f379e7f69aada669 (diff)
run ConnectHandler and DisconnectHandler in goroutines
Diffstat (limited to 'catbus.go')
-rw-r--r--catbus.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/catbus.go b/catbus.go
index 2a3a120..66cab2e 100644
--- a/catbus.go
+++ b/catbus.go
@@ -82,14 +82,14 @@ func NewClient(brokerURI string, options ClientOptions) Client {
client.startAllTimers()
if options.ConnectHandler != nil {
- options.ConnectHandler(client)
+ go options.ConnectHandler(client)
}
})
mqttOpts.SetConnectionLostHandler(func(_ mqtt.Client, err error) {
client.stopAllTimers()
if options.DisconnectHandler != nil {
- options.DisconnectHandler(client, err)
+ go options.DisconnectHandler(client, err)
}
})
client.mqtt = mqtt.NewClient(mqttOpts)