Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughAdds MessageExtras support to presence APIs and PresenceMessage: new extras-accepting overloads for enter/update/leave (including clientId variants), PresenceMessage gains an extras field with serialization/deserialization support, Kotlin interfaces/adapters updated, and tests added (with a duplicated test block present). Changes
Sequence DiagramsequenceDiagram
participant Client
participant Presence
participant PresenceMessage
participant Network
Client->>Presence: enter(data, extras, listener)
Presence->>PresenceMessage: new PresenceMessage(action, clientId, data, extras)
PresenceMessage-->>Presence: constructed (includes extras)
Presence->>Network: serialize PresenceMessage (JSON/msgpack includes extras)
Network-->>Presence: deliver PresenceMessage payload
Presence->>PresenceMessage: deserialize/read (extract extras)
Presence-->>Client: emit PresenceMessage (with extras)
Client->>Client: listener.onSuccess()
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 <noreply@anthropic.com>
dabc3d8 to
8e5acc4
Compare
There was a problem hiding this comment.
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.
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). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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).RealtimePresenceinterface andRealtimePresenceAdapterwith theextrasparameter (defaulting tonull).PresenceMessage.read()now handles"extras": nullgracefully instead of throwing.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) formatsnullextras gracefully and type-checks for valid JSON objectPresence.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)RealtimePresence.kt/RealtimePresenceAdapter.ktextras: MessageExtras? = nullparameter to all 6 presence methods in the Kotlin interface and adapterRealtimePresenceTest.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
New Features
Tests
Compatibility