Skip to content

Commit

Permalink
Deprecated IsSyncComplete property, added SyncComplete property as pe…
Browse files Browse the repository at this point in the history
…r spec
  • Loading branch information
sacOO7 committed Apr 19, 2024
1 parent 54ebec3 commit 332d954
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
14 changes: 12 additions & 2 deletions src/IO.Ably.Shared/Realtime/Presence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,18 @@ internal Presence(IConnectionManager connection, RealtimeChannel channel, string

/// <summary>
/// Has the sync completed.
/// RTP13

Check failure on line 43 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

Check failure on line 43 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 43 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

Check failure on line 43 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 43 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 43 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

/// </summary>
public bool IsSyncComplete => MembersMap.SyncCompleted && !IsSyncInProgress;
///
[Obsolete("This property is deprecated, use SyncComplete instead")]
public bool IsSyncComplete => SyncComplete;

/// <summary>
/// Checks if sync has completed
/// RTP13

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

Check failure on line 51 in src/IO.Ably.Shared/Realtime/Presence.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

/// </summary>
///
public bool SyncComplete => MembersMap.SyncCompleted && !IsSyncInProgress;

/// <summary>
/// Indicates whether there is currently a sync in progress.
Expand Down Expand Up @@ -153,7 +163,7 @@ private async Task<bool> WaitForSyncAsync()
// The InternalSync should be completed and the channels Attached or Attaching
void CheckAndSet()
{
if (IsSyncComplete
if (SyncComplete
&& (_channel.State == ChannelState.Attached || _channel.State == ChannelState.Attaching))
{
tsc.TrySetResult(true);
Expand Down
12 changes: 6 additions & 6 deletions src/IO.Ably.Tests.Shared/Realtime/PresenceSandboxSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public async Task WhenAttachingToAChannelWithNoMembers_PresenceShouldBeConsidere
await channel.WaitForAttachedState();
channel.State.Should().Be(ChannelState.Attached);

channel.Presence.IsSyncComplete.Should().BeTrue();
channel.Presence.SyncComplete.Should().BeTrue();
}

[Theory]
Expand Down Expand Up @@ -110,7 +110,7 @@ public async Task WhenAttachingToAChannelWithMembers_PresenceShouldBeInProgress(
{
Logger.Debug("Test: Setting inSync to - " + channel2.Presence.MembersMap.SyncInProgress);
syncInProgress = channel2.Presence.IsSyncInProgress;
syncComplete = channel2.Presence.IsSyncComplete;
syncComplete = channel2.Presence.SyncComplete;
awaiter.SetCompleted();
}
};
Expand Down Expand Up @@ -741,7 +741,7 @@ public async Task PresenceMap_WhenNotSyncingAndLeaveActionArrivesMemberKeyShould

// sync should not be in progress and initial an sync should have completed
channel.Presence.IsSyncInProgress.Should().BeFalse("sync should have completed");
channel.Presence.IsSyncComplete.Should().BeTrue();
channel.Presence.SyncComplete.Should().BeTrue();

// pull a random member key from the presence map
var memberNumber = new Random().Next(0, 19);
Expand Down Expand Up @@ -1504,19 +1504,19 @@ await WaitForMultiple(2, partialDone =>
presence2.Subscribe(PresenceAction.Enter, msg =>
{
presence2.MembersMap.Members.Should().HaveCount(presence2.IsSyncComplete ? 2 : 1);
presence2.MembersMap.Members.Should().HaveCount(presence2.SyncComplete ? 2 : 1);
presence2.Unsubscribe();
partialDone();
});
presence2.PendingPresenceQueue.Should().HaveCount(1);
presence2.IsSyncComplete.Should().BeFalse();
presence2.SyncComplete.Should().BeFalse();
presence2.MembersMap.Members.Should().HaveCount(0);
taskCountWaiter.Tick();
});

var transport = client2.GetTestTransport();
await new ConditionalAwaiter(() => presence2.IsSyncComplete);
await new ConditionalAwaiter(() => presence2.SyncComplete);
transport.ProtocolMessagesReceived.Any(m => m.Action == ProtocolMessage.MessageAction.Sync).
Should().BeTrue("Should receive sync message");
presence2.MembersMap.Members.Should().HaveCount(2);
Expand Down

0 comments on commit 332d954

Please sign in to comment.