From 131826e1d138a98066813faa284da377bb99ecbe Mon Sep 17 00:00:00 2001 From: Wim Date: Fri, 19 Aug 2016 22:58:42 +0200 Subject: Fix crash on exit --- matterclient/matterclient.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index ff3036b4..f3e188a0 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -197,11 +197,6 @@ func (m *MMClient) WsReceiver() { for { var rawMsg json.RawMessage var err error - if _, rawMsg, err = m.WsClient.ReadMessage(); err != nil { - m.log.Error("error:", err) - // reconnect - m.Login() - } if !m.WsConnected { continue @@ -211,6 +206,12 @@ func (m *MMClient) WsReceiver() { return } + if _, rawMsg, err = m.WsClient.ReadMessage(); err != nil { + m.log.Error("error:", err) + // reconnect + m.Login() + } + var event model.WebSocketEvent if err := json.Unmarshal(rawMsg, &event); err == nil && event.IsValid() { m.log.Debugf("WsReceiver: %#v", event) -- cgit v1.2.3