Skip to content

Commit

Permalink
Refactored realtimeworkflow for resume or recover success
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Sep 7, 2023
1 parent 8bf8ac0 commit c0daf2e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/IO.Ably.Shared/Realtime/Workflows/RealtimeWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ private void HandleConnectedCommand(SetConnectedStateCommand cmd)
{
var info = new ConnectionInfo(cmd.Message);

var resumeOrRecoverSuccess = State.Connection.IsResumed(info) && cmd.Message.Error == null;
var isResumedOrRecoveredConnection = State.Connection.Key.IsNotEmpty() || Client.Options.Recover.IsNotEmpty(); // recover will only be used during init, resume will be used for all subsequent requests
var isConnectionResumeOrRecoverAttempt = State.Connection.Key.IsNotEmpty() || Client.Options.Recover.IsNotEmpty(); // recover will only be used during init, resume will be used for all subsequent requests
var resumeOrRecoverSuccess = State.Connection.IsResumed(info) && cmd.Message.Error == null; // RTN15c6

State.Connection.Update(info);

Expand All @@ -620,13 +620,13 @@ private void HandleConnectedCommand(SetConnectedStateCommand cmd)
Client.Options.Recover = null; // RTN16k, explicitly setting null so it won't be used for subsequent connection requests

// RTN15c7
if (isResumedOrRecoveredConnection && !resumeOrRecoverSuccess)
if (isConnectionResumeOrRecoverAttempt && !resumeOrRecoverSuccess)
{
State.Connection.MessageSerial = 0;
}

// RTN15g3, RTN15c6, RTN15c7, RTN16l - for resume/recovered or when connection ttl passed, re-attach channels
if (State.Connection.HasConnectionStateTtlPassed(Now) || isResumedOrRecoveredConnection)
if (State.Connection.HasConnectionStateTtlPassed(Now) || isConnectionResumeOrRecoverAttempt)
{
foreach (var channel in Channels)
{
Expand Down

0 comments on commit c0daf2e

Please sign in to comment.