5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-25 04:55:41 +00:00

Fix crash on exit

This commit is contained in:
Wim 2016-08-19 22:58:42 +02:00
parent 96e21dd051
commit 131826e1d1

View File

@ -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)