Skip to content

Commit

Permalink
Fixed logic for checking newer presence message
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Jan 16, 2024
1 parent b185b71 commit 3cddaaf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ably/proto_presence_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (msg *PresenceMessage) getMsgSerialAndIndex() (int64, int64, error) {
func (msg1 *PresenceMessage) IsNewerThan(msg2 *PresenceMessage) (bool, error) {
// RTP2b1
if msg1.isServerSynthesized() || msg2.isServerSynthesized() {
return msg1.Timestamp > msg2.Timestamp, nil
return msg1.Timestamp >= msg2.Timestamp, nil
}

// RTP2b2
Expand All @@ -98,7 +98,7 @@ func (msg1 *PresenceMessage) IsNewerThan(msg2 *PresenceMessage) (bool, error) {
return true, err
}
if msg1Serial == msg2Serial {
return msg1Index > msg2Index, nil
return msg1Index >= msg2Index, nil
}
return msg1Serial > msg2Serial, nil
}
2 changes: 1 addition & 1 deletion ably/proto_presence_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ func Test_internal_presencemap_RTP17(t *testing.T) {
Action: ably.PresenceActionLeave,
Message: ably.Message{
ID: "987:12:3",
Timestamp: 125,
Timestamp: 124,
ConnectionID: client.Connection.ID(),
ClientID: "978",
},
Expand Down

0 comments on commit 3cddaaf

Please sign in to comment.