Skip to content

Commit

Permalink
Simplified processing of sync and normal presence message
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Sep 3, 2023
1 parent 8ccc633 commit 0a28b87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/IO.Ably.Shared/Realtime/ChannelMessageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,14 @@ public Task<bool> MessageReceived(ProtocolMessage protocolMessage, RealtimeState
channel.OnError(presenceDecodeResult.Error);
}

string syncSerial = protocolMessage.Action == ProtocolMessage.MessageAction.Sync
? protocolMessage.ChannelSerial
: null;

channel.Presence.OnPresence(protocolMessage.Presence, syncSerial);
if (protocolMessage.Action == ProtocolMessage.MessageAction.Sync)
{
channel.Presence.OnSyncMessage(protocolMessage);
}
else
{
channel.Presence.OnPresence(protocolMessage.Presence, null);
}

break;
}
Expand Down
5 changes: 5 additions & 0 deletions src/IO.Ably.Shared/Realtime/Presence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,11 @@ private bool PendingPresenceEnqueue(QueuedPresenceMessage msg)
return true;
}

internal void OnSyncMessage(ProtocolMessage protocolMessage)
{
OnPresence(protocolMessage.Presence, protocolMessage.ChannelSerial);
}

internal void OnPresence(PresenceMessage[] messages, string syncChannelSerial)
{
try
Expand Down

0 comments on commit 0a28b87

Please sign in to comment.