From e46ce92706a51b2c404a4b2621425d43289f7f23 Mon Sep 17 00:00:00 2001 From: Sergei Vizel Date: Thu, 20 Sep 2018 09:22:09 +0300 Subject: [PATCH] stop reconnect, if the server sends advise.reconnect==none --- transport/websocket/websocket.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/transport/websocket/websocket.go b/transport/websocket/websocket.go index 9dc49ee..210f59b 100644 --- a/transport/websocket/websocket.go +++ b/transport/websocket/websocket.go @@ -86,6 +86,10 @@ func (w *Websocket) readWorker() error { //handle it switch msg.Channel { case transport.MetaConnect: + advise := w.advice.Load().(*message.Advise) + if advise.Reconnect == message.ReconnectNone { + return w.Disconnect() + } m := message.Message{ Channel: transport.MetaConnect, ClientId: w.clientID, @@ -251,8 +255,9 @@ func (w *Websocket) Connect() error { } go func () { - err := w.readWorker() - w.onError(err) + if err := w.readWorker(); err != nil { + w.onError(err) + } }() return w.sendMessage(&m)