Skip to content

Commit f903317

Browse files
AndyTWFclaude
andcommitted
feat: add extras parameter to Kotlin presence wrappers
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>
1 parent 1ef7829 commit f903317

2 files changed

Lines changed: 31 additions & 21 deletions

File tree

pubsub-adapter/src/main/kotlin/com/ably/pubsub/RealtimePresence.kt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.ably.Subscription
44
import io.ably.lib.realtime.ChannelState
55
import io.ably.lib.realtime.CompletionListener
66
import io.ably.lib.realtime.Presence.PresenceListener
7+
import io.ably.lib.types.MessageExtras
78
import io.ably.lib.types.PresenceMessage
89
import java.util.*
910

@@ -71,59 +72,63 @@ public interface RealtimePresence : Presence {
7172
public fun subscribe(actions: EnumSet<PresenceMessage.Action>, listener: PresenceListener): Subscription
7273

7374
/**
74-
* Enters the presence set for the channel, optionally passing a data payload.
75+
* Enters the presence set for the channel, optionally passing a data payload and extras.
7576
* A clientId is required to be present on a channel.
7677
* An optional callback may be provided to notify of the success or failure of the operation.
7778
*
7879
* Spec: RTP8
7980
*
8081
* @param data The payload associated with the presence member.
82+
* @param extras The extras associated with the presence member.
8183
* @param listener A callback to notify of the success or failure of the operation.
8284
* This listener is invoked on a background thread.
8385
*/
84-
public fun enter(data: Any? = null, listener: CompletionListener? = null)
86+
public fun enter(data: Any? = null, extras: MessageExtras? = null, listener: CompletionListener? = null)
8587

8688
/**
87-
* Updates the data payload for a presence member.
89+
* Updates the data payload for a presence member, optionally passing extras.
8890
* If called before entering the presence set, this is treated as an [PresenceMessage.Action.enter] event.
8991
* An optional callback may be provided to notify of the success or failure of the operation.
9092
*
9193
* Spec: RTP9
9294
*
9395
* @param data The payload associated with the presence member.
96+
* @param extras The extras associated with the presence member.
9497
* @param listener A callback to notify of the success or failure of the operation.
9598
* This listener is invoked on a background thread.
9699
*/
97-
public fun update(data: Any? = null, listener: CompletionListener? = null)
100+
public fun update(data: Any? = null, extras: MessageExtras? = null, listener: CompletionListener? = null)
98101

99102
/**
100-
* Leaves the presence set for the channel.
103+
* Leaves the presence set for the channel, optionally passing extras.
101104
* A client must have previously entered the presence set before they can leave it.
102105
*
103106
* Spec: RTP10
104107
*
105108
* @param data The payload associated with the presence member.
109+
* @param extras The extras associated with the presence member.
106110
* @param listener a listener to notify of the success or failure of the operation.
107111
* This listener is invoked on a background thread.
108112
*/
109-
public fun leave(data: Any? = null, listener: CompletionListener? = null)
113+
public fun leave(data: Any? = null, extras: MessageExtras? = null, listener: CompletionListener? = null)
110114

111115
/**
112-
* Enters the presence set of the channel for a given clientId.
116+
* Enters the presence set of the channel for a given clientId, optionally passing extras.
113117
* Enables a single client to update presence on behalf of any number of clients using a single connection.
114118
* The library must have been instantiated with an API key or a token bound to a wildcard clientId.
115119
*
116120
* Spec: RTP4, RTP14, RTP15
117121
*
118122
* @param clientId The ID of the client to enter into the presence set.
119123
* @param data The payload associated with the presence member.
124+
* @param extras The extras associated with the presence member.
120125
* @param listener A callback to notify of the success or failure of the operation.
121126
* This listener is invoked on a background thread.
122127
*/
123-
public fun enterClient(clientId: String, data: Any? = null, listener: CompletionListener? = null)
128+
public fun enterClient(clientId: String, data: Any? = null, extras: MessageExtras? = null, listener: CompletionListener? = null)
124129

125130
/**
126-
* Updates the data payload for a presence member using a given clientId.
131+
* Updates the data payload for a presence member using a given clientId, optionally passing extras.
127132
* Enables a single client to update presence on behalf of any number of clients using a single connection.
128133
* The library must have been instantiated with an API key or a token bound to a wildcard clientId.
129134
* An optional callback may be provided to notify of the success or failure of the operation.
@@ -132,22 +137,24 @@ public interface RealtimePresence : Presence {
132137
*
133138
* @param clientId The ID of the client to update in the presence set.
134139
* @param data The payload to update for the presence member.
140+
* @param extras The extras associated with the presence member.
135141
* @param listener A callback to notify of the success or failure of the operation.
136142
* This listener is invoked on a background thread.
137143
*/
138-
public fun updateClient(clientId: String, data: Any? = null, listener: CompletionListener? = null)
144+
public fun updateClient(clientId: String, data: Any? = null, extras: MessageExtras? = null, listener: CompletionListener? = null)
139145

140146
/**
141-
* Leaves the presence set of the channel for a given clientId.
147+
* Leaves the presence set of the channel for a given clientId, optionally passing extras.
142148
* Enables a single client to update presence on behalf of any number of clients using a single connection.
143149
* The library must have been instantiated with an API key or a token bound to a wildcard clientId.
144150
*
145151
* Spec: RTP15
146152
*
147153
* @param clientId The ID of the client to leave the presence set for.
148154
* @param data The payload associated with the presence member.
155+
* @param extras The extras associated with the presence member.
149156
* @param listener A callback to notify of the success or failure of the operation.
150157
* This listener is invoked on a background thread.
151158
*/
152-
public fun leaveClient(clientId: String?, data: Any? = null, listener: CompletionListener? = null)
159+
public fun leaveClient(clientId: String?, data: Any? = null, extras: MessageExtras? = null, listener: CompletionListener? = null)
153160
}

pubsub-adapter/src/main/kotlin/io/ably/lib/realtime/RealtimePresenceAdapter.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,23 @@ internal class RealtimePresenceAdapter(private val javaPresence: Presence) : Rea
4444
}
4545
}
4646

47-
override fun enter(data: Any?, listener: CompletionListener?) = javaPresence.enter(data, listener)
47+
override fun enter(data: Any?, extras: MessageExtras?, listener: CompletionListener?) =
48+
javaPresence.enter(data, extras, listener)
4849

49-
override fun update(data: Any?, listener: CompletionListener?) = javaPresence.update(data, listener)
50+
override fun update(data: Any?, extras: MessageExtras?, listener: CompletionListener?) =
51+
javaPresence.update(data, extras, listener)
5052

51-
override fun leave(data: Any?, listener: CompletionListener?) = javaPresence.leave(data, listener)
53+
override fun leave(data: Any?, extras: MessageExtras?, listener: CompletionListener?) =
54+
javaPresence.leave(data, extras, listener)
5255

53-
override fun enterClient(clientId: String, data: Any?, listener: CompletionListener?) =
54-
javaPresence.enterClient(clientId, data, listener)
56+
override fun enterClient(clientId: String, data: Any?, extras: MessageExtras?, listener: CompletionListener?) =
57+
javaPresence.enterClient(clientId, data, extras, listener)
5558

56-
override fun updateClient(clientId: String, data: Any?, listener: CompletionListener?) =
57-
javaPresence.updateClient(clientId, data, listener)
59+
override fun updateClient(clientId: String, data: Any?, extras: MessageExtras?, listener: CompletionListener?) =
60+
javaPresence.updateClient(clientId, data, extras, listener)
5861

59-
override fun leaveClient(clientId: String?, data: Any?, listener: CompletionListener?) =
60-
javaPresence.leaveClient(clientId, data, listener)
62+
override fun leaveClient(clientId: String?, data: Any?, extras: MessageExtras?, listener: CompletionListener?) =
63+
javaPresence.leaveClient(clientId, data, extras, listener)
6164

6265
override fun history(start: Long?, end: Long?, limit: Int, orderBy: OrderBy): PaginatedResult<PresenceMessage> =
6366
javaPresence.history(buildHistoryParams(start, end, limit, orderBy).toTypedArray())

0 commit comments

Comments
 (0)