Skip to content

Commit

Permalink
Refactored msg synthesize, renamed to serverSynthesized
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Apr 19, 2024
1 parent 5c77955 commit fd91156
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/IO.Ably.Shared/Extensions/PresenceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
internal static class PresenceExtensions
{
public static bool IsSynthesized(this PresenceMessage msg)
public static bool IsServerSynthesized(this PresenceMessage msg)
{
return msg.Id == null || !msg.Id.StartsWith(msg.ConnectionId);
}
Expand All @@ -11,7 +11,7 @@ public static bool IsSynthesized(this PresenceMessage msg)
public static bool IsNewerThan(this PresenceMessage existingMsg, PresenceMessage incomingMsg)
{
// RTP2b1
if (existingMsg.IsSynthesized() || incomingMsg.IsSynthesized())
if (existingMsg.IsServerSynthesized() || incomingMsg.IsServerSynthesized())
{
return existingMsg.Timestamp > incomingMsg.Timestamp;
}
Expand Down
2 changes: 1 addition & 1 deletion src/IO.Ably.Shared/Realtime/Presence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ internal void OnPresence(PresenceMessage[] messages)
// RTP2e
case PresenceAction.Leave:
broadcast &= MembersMap.Remove(message);
if (updateInternalPresence && !message.IsSynthesized())
if (updateInternalPresence && !message.IsServerSynthesized())
{
InternalMembersMap.Remove(message);
}
Expand Down
2 changes: 1 addition & 1 deletion src/IO.Ably.Tests.Shared/Realtime/PresenceSandboxSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ await WaitForMultiple(2, partialDone =>
msgA = null;
msgB = null;
var synthesizedMsg = new PresenceMessage(PresenceAction.Leave, clientB.ClientId) { ConnectionId = null };
synthesizedMsg.IsSynthesized().Should().BeTrue();
synthesizedMsg.IsServerSynthesized().Should().BeTrue();
channelB.Presence.OnPresence(new[] { synthesizedMsg });

msgB.Should().BeNull();
Expand Down

0 comments on commit fd91156

Please sign in to comment.