diff --git a/client.go b/client.go index 907b5679..72bcf469 100644 --- a/client.go +++ b/client.go @@ -70,6 +70,8 @@ type Client struct { // the client will not attempt to reconnect. The number of retries can be read from AutoReconnectErrors. AutoReconnectHook func(error) bool + DisableLoginAutoReconnect bool + sendActiveReceipts atomic.Uint32 // EmitAppStateEventsOnFullSync can be set to true if you want to get app state events emitted diff --git a/connectionevents.go b/connectionevents.go index 5feaed25..2a2a5be8 100644 --- a/connectionevents.go +++ b/connectionevents.go @@ -23,6 +23,11 @@ func (cli *Client) handleStreamError(node *waBinary.Node) { conflictType := conflict.AttrGetter().OptionalString("type") switch { case code == "515": + if cli.DisableLoginAutoReconnect { + cli.Log.Infof("Got 515 code, but login autoreconnect is disabled, not reconnecting") + cli.dispatchEvent(&events.ManualLoginReconnect{}) + return + } cli.Log.Infof("Got 515 code, reconnecting...") go func() { cli.Disconnect() diff --git a/types/events/events.go b/types/events/events.go index 6ab6c202..be0c8524 100644 --- a/types/events/events.go +++ b/types/events/events.go @@ -110,6 +110,9 @@ type LoggedOut struct { // or otherwise try to connect twice with the same session. type StreamReplaced struct{} +// ManualLoginReconnect is emitted after login if DisableLoginAutoReconnect is set. +type ManualLoginReconnect struct{} + // TempBanReason is an error code included in temp ban error events. type TempBanReason int