summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-09-05 23:08:17 +0200
committerWim <wim@42.be>2016-09-05 23:08:17 +0200
commit0f530e7902f71c8f66b6b697a7d004e9f45bd9da (patch)
treec0dcea98f2ab34f0e99d01acad6d95345edec1d1
parent4ed66ce20e7c7e304e702639ff7215ed2ddbb57f (diff)
downloadmatterbridge-msglm-0f530e7902f71c8f66b6b697a7d004e9f45bd9da.tar.gz
matterbridge-msglm-0f530e7902f71c8f66b6b697a7d004e9f45bd9da.tar.bz2
matterbridge-msglm-0f530e7902f71c8f66b6b697a7d004e9f45bd9da.zip
Fix spinning for loop
-rw-r--r--matterclient/matterclient.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go
index 0ee8fff1..beb14de0 100644
--- a/matterclient/matterclient.go
+++ b/matterclient/matterclient.go
@@ -185,7 +185,6 @@ func (m *MMClient) Logout() error {
m.WsQuit = true
m.WsClient.Close()
m.WsClient.UnderlyingConn().Close()
- m.WsClient = nil
_, err := m.Client.Logout()
if err != nil {
return err
@@ -198,14 +197,16 @@ func (m *MMClient) WsReceiver() {
var rawMsg json.RawMessage
var err error
- if !m.WsConnected {
- continue
- }
if m.WsQuit {
m.log.Debug("exiting WsReceiver")
return
}
+ if !m.WsConnected {
+ time.Sleep(time.Millisecond * 100)
+ continue
+ }
+
if _, rawMsg, err = m.WsClient.ReadMessage(); err != nil {
m.log.Error("error:", err)
// reconnect