diff options
author | Wim <wim@42.be> | 2016-08-19 22:58:42 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2016-08-19 22:58:42 +0200 |
commit | 131826e1d138a98066813faa284da377bb99ecbe (patch) | |
tree | c1ae582745ad0b8e310fbdff0e5cef13c1840e13 /matterclient | |
parent | 96e21dd0511cd08ca2d9581a5c7299e91a2ea984 (diff) | |
download | matterbridge-msglm-131826e1d138a98066813faa284da377bb99ecbe.tar.gz matterbridge-msglm-131826e1d138a98066813faa284da377bb99ecbe.tar.bz2 matterbridge-msglm-131826e1d138a98066813faa284da377bb99ecbe.zip |
Fix crash on exit
Diffstat (limited to 'matterclient')
-rw-r--r-- | matterclient/matterclient.go | 11 |
1 files 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) |