From a64a479e3a0c8834dc6a43979370b0c19ce041a3 Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Sat, 28 Oct 2023 21:22:06 +0530 Subject: [PATCH] Refactored code for connectionResumeorRecoverAttempt --- ably/realtime_conn.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ably/realtime_conn.go b/ably/realtime_conn.go index ea85473f..65da541b 100644 --- a/ably/realtime_conn.go +++ b/ably/realtime_conn.go @@ -793,6 +793,9 @@ func (c *Connection) eventloop() { case actionConnected: c.mtx.Lock() + // recover is used when set via clientOptions#recover initially, resume will be used for all subsequent requests. + isConnectionResumeOrRecoverAttempt := !empty(c.key) || !empty(c.opts.Recover) + // we need to get this before we set c.key so as to be sure if we were // resuming or recovering the connection. mode := c.getMode() @@ -823,9 +826,6 @@ func (c *Connection) eventloop() { c.id = msg.ConnectionID isNewID := previousID != msg.ConnectionID - // recover is used when set via clientOptions#recover initially, resume will be used for all subsequent requests. - isConnectionResumeOrRecoverAttempt := !empty(c.key) || !empty(c.opts.Recover) - failedResumeOrRecover := isNewID && msg.Error != nil // RTN15c7, RTN16d if reconnecting && mode == recoveryMode && msg.Error == nil {