Skip to content

Commit

Permalink
Refactored presence file for handling on Presence
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Dec 5, 2023
1 parent 0cab20f commit 6fb8686
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/src/main/java/io/ably/lib/realtime/Presence.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private void endSync() {
broadcastPresence(residualMembers);
}

private void updateInnerMessageFields(ProtocolMessage message) {
private void updateInnerPresenceMessageFields(ProtocolMessage message) {
for(int i = 0; i < message.presence.length; i++) {
PresenceMessage msg = message.presence[i];
try {
Expand Down Expand Up @@ -386,7 +386,7 @@ void onSync(ProtocolMessage protocolMessage) {
}

void onPresence(ProtocolMessage protocolMessage) {
updateInnerMessageFields(protocolMessage);
updateInnerPresenceMessageFields(protocolMessage);
List<PresenceMessage> updatedPresenceMessages = new ArrayList<>();
for(PresenceMessage presenceMessage : protocolMessage.presence) {
boolean updateInternalPresence = presenceMessage.connectionId.equals(channel.ably.connection.id);
Expand All @@ -396,9 +396,9 @@ void onPresence(ProtocolMessage protocolMessage) {
case enter:
case update:
case present:
PresenceMessage shallowClone = (PresenceMessage)presenceMessage.clone();
shallowClone.action = PresenceMessage.Action.present;
memberUpdated = presence.put(shallowClone);
PresenceMessage shallowPresenceCopy = (PresenceMessage)presenceMessage.clone();
shallowPresenceCopy.action = PresenceMessage.Action.present;
memberUpdated = presence.put(shallowPresenceCopy);
if(updateInternalPresence)
internalPresence.put(presenceMessage);
break;
Expand Down

0 comments on commit 6fb8686

Please sign in to comment.