5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-25 22:31:35 +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 { for {
var rawMsg json.RawMessage var rawMsg json.RawMessage
var err error var err error
if _, rawMsg, err = m.WsClient.ReadMessage(); err != nil {
m.log.Error("error:", err)
// reconnect
m.Login()
}
if !m.WsConnected { if !m.WsConnected {
continue continue
@ -211,6 +206,12 @@ func (m *MMClient) WsReceiver() {
return return
} }
if _, rawMsg, err = m.WsClient.ReadMessage(); err != nil {
m.log.Error("error:", err)
// reconnect
m.Login()
}
var event model.WebSocketEvent var event model.WebSocketEvent
if err := json.Unmarshal(rawMsg, &event); err == nil && event.IsValid() { if err := json.Unmarshal(rawMsg, &event); err == nil && event.IsValid() {
m.log.Debugf("WsReceiver: %#v", event) m.log.Debugf("WsReceiver: %#v", event)