From 5d0003e5a36359afa21d6509de330b9fa2e81d70 Mon Sep 17 00:00:00 2001 From: Ethel Morgan Date: Tue, 30 Jun 2020 15:38:57 +0100 Subject: run ConnectHandler and DisconnectHandler in goroutines --- catbus.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'catbus.go') 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) -- cgit v1.2.3