Fix crash on exit

This commit is contained in:
Wim 2016-08-19 22:58:42 +02:00
parent 96e21dd051
commit 131826e1d1
1 changed files with 6 additions and 5 deletions

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)