-
Notifications
You must be signed in to change notification settings - Fork 42
Add MessageExtras support to PresenceMessage #1191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughAdds MessageExtras support to Presence APIs and PresenceMessage: new overloads for enter/update/leave (including clientId variants), PresenceMessage gains an extras field and serialization handling, tests added, and Kotlin adapter/interface updated to accept and forward extras. Changes
Sequence DiagramsequenceDiagram
participant Client as Client
participant Presence as Presence
participant PM as PresenceMessage
participant Network as Network/Server
Client->>Presence: enter(data, extras, listener)
Presence->>Presence: enterClientWithId(..., extras)
Presence->>PM: new PresenceMessage(action, clientId, data, extras)
PM->>PM: store extras field
Presence->>Network: serialize PresenceMessage (includes extras)
Network-->>Presence: deliver PresenceMessage JSON/msgpack
Presence->>PM: deserialize (reads extras)
Presence-->>Client: emit PresenceMessage(with extras)
Client->>Client: listener.onSuccess()
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add extras field to PresenceMessage type with support for both msgpack and JSON serialization/deserialization. Includes end-to-end test verifying extras round-trip through presence enter. Co-Authored-By: Claude Opus 4.6 <[email protected]>
dabc3d8 to
8e5acc4
Compare
Add MessageExtras overloads to enter(), update(), leave() and their *Client variants so callers can pass extras without dropping down to updatePresence(PresenceMessage, CompletionListener). Existing methods delegate to the new overloads with null extras (fully backward-compatible). Also fixes a bug in enterInternalMembers() (RTP17g) where extras were dropped on automatic re-enter after reconnect. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Update RealtimePresence interface and RealtimePresenceAdapter to accept MessageExtras on enter, update, leave and their *Client variants, matching the new Java overloads. The extras parameter defaults to null so existing callers are unaffected. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@lib/src/main/java/io/ably/lib/types/PresenceMessage.java`:
- Around line 293-309: The read method in PresenceMessage currently throws when
extras is the JSON literal null; update PresenceMessage.read to treat JsonNull
as absent by checking extrasElement.isJsonNull() (or instanceof JsonNull) and
skipping the extras parsing instead of erroring, so only non-null JsonObject
values are passed to MessageExtras.read; reference the EXTRAS lookup, the
extrasElement variable, and MessageExtras.read when making this change.
Treat `"extras": null` as absent rather than throwing a MessageDecodeException. This avoids a hard failure when incoming JSON explicitly sets extras to null. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary
This change adds full support for
MessageExtrason presence messages:PresenceMessage.extrasfield (TP3i) — allows presence messages to carry arbitrary metadata and ancillary payloads, with serialization support in both MessagePack and JSON formats.MessageExtrasoverloads toenter(),update(),leave()and their*Clientvariants so callers can pass extras without dropping down toupdatePresence(PresenceMessage, CompletionListener).enterInternalMembers()now passesitem.extrasthrough when automatically re-entering after reconnect, where previously extras were dropped.CHA-1243
Prerequisite to ably/ably-chat-kotlin#193
Closes #736
Closes #753
Key Changes
PresenceMessage.javaextrasfield of typeMessageExtras(TP3i)PresenceMessage(Action, String, Object, MessageExtras); existing 3-arg constructor delegates to it withextras = nullclone()to copy theextrasfieldextrasin both MessagePack (writeMsgpack/readMsgpack) and JSON (read/Serializer) formatsPresence.javaMessageExtras extrasparameter:enter(Object data, MessageExtras extras, CompletionListener listener)— RTP8update(Object data, MessageExtras extras, CompletionListener listener)— RTP9leave(Object data, MessageExtras extras, CompletionListener listener)— RTP10enterClient(String clientId, Object data, MessageExtras extras, CompletionListener listener)— RTP15updateClient(String clientId, Object data, MessageExtras extras, CompletionListener listener)— RTP15leaveClient(String clientId, Object data, MessageExtras extras, CompletionListener listener)— RTP15nullextras (fully backward-compatible, no ambiguity — different arity)enterClientWithId()now accepts and passes throughMessageExtrasenterInternalMembers()passesitem.extrason re-enter (RTP17g)RealtimePresenceTest.javapresence_enter_with_extras— existing test for extras viaupdatePresence()directlypresence_enter_with_extras_convenience— new: testsenter(data, extras, listener)presence_update_with_extras— new: testsupdate(data, extras, listener)presence_leave_with_extras— new: testsleave(data, extras, listener)presence_enterClient_with_extras— new: testsenterClient(clientId, data, extras, listener)Backward Compatibility
All changes are fully backward-compatible. No existing method signatures change. Java overload resolution is clean since the new methods differ in arity from the existing ones.
🤖 Generated with Claude Code
Summary by CodeRabbit