Skip to content

Commit 63dad64

Browse files
committed
[ECO-5458] Updated core LiveObjects implementation for subscriptions
- Modified DefaultLiveObjects to support subscription integration - Enhanced Helpers with subscription-related utilities - Updated ObjectsManager and ObjectsPool for subscription context
1 parent 59bf9b3 commit 63dad64

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjects.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package io.ably.lib.objects
22

33
import io.ably.lib.objects.state.ObjectsStateChange
44
import io.ably.lib.objects.state.ObjectsStateEvent
5+
import io.ably.lib.objects.type.counter.LiveCounter
6+
import io.ably.lib.objects.type.map.LiveMap
57
import io.ably.lib.realtime.ChannelState
68
import io.ably.lib.types.AblyException
79
import io.ably.lib.types.ProtocolMessage
@@ -125,7 +127,7 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
125127
* @spec OM2 - Populates missing fields from parent protocol message
126128
*/
127129
private fun initializeHandlerForIncomingObjectMessages(): Job {
128-
return sequentialScope.launch {
130+
return sequentialScope.launch {
129131
objectsEventBus.collect { protocolMessage ->
130132
// OM2 - Populate missing fields from parent
131133
val objects = protocolMessage.state.filterIsInstance<ObjectMessage>()

live-objects/src/main/kotlin/io/ably/lib/objects/Helpers.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ internal fun LiveObjectsAdapter.setChannelSerial(channelName: String, protocolMe
4141
setChannelSerial(channelName, channelSerial)
4242
}
4343

44+
// Spec: RTLO4b1, RTLO4b2
4445
internal fun LiveObjectsAdapter.throwIfInvalidAccessApiConfiguration(channelName: String) {
4546
throwIfMissingChannelMode(channelName, ChannelMode.object_subscribe)
4647
throwIfInChannelState(channelName, arrayOf(ChannelState.detached, ChannelState.failed))

live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.ably.lib.objects
22

33
import io.ably.lib.objects.type.BaseLiveObject
4+
import io.ably.lib.objects.type.LiveObjectUpdate
45
import io.ably.lib.objects.type.livecounter.DefaultLiveCounter
56
import io.ably.lib.objects.type.livemap.DefaultLiveMap
67
import io.ably.lib.util.Log
@@ -125,7 +126,8 @@ internal class ObjectsManager(private val liveObjects: DefaultLiveObjects): Obje
125126
}
126127

127128
val receivedObjectIds = mutableSetOf<String>()
128-
val existingObjectUpdates = mutableListOf<Pair<BaseLiveObject, Any>>()
129+
// RTO5c1a2 - List to collect updates for existing objects
130+
val existingObjectUpdates = mutableListOf<Pair<BaseLiveObject, LiveObjectUpdate>>()
129131

130132
// RTO5c1
131133
for ((objectId, objectState) in syncObjectsDataPool) {
@@ -148,7 +150,7 @@ internal class ObjectsManager(private val liveObjects: DefaultLiveObjects): Obje
148150
// RTO5c2 - need to remove LiveObject instances from the ObjectsPool for which objectIds were not received during the sync sequence
149151
liveObjects.objectsPool.deleteExtraObjectIds(receivedObjectIds)
150152

151-
// call subscription callbacks for all updated existing objects
153+
// RTO5c7 - call subscription callbacks for all updated existing objects
152154
existingObjectUpdates.forEach { (obj, update) ->
153155
obj.notifyUpdated(update)
154156
}

live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsPool.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ internal class ObjectsPool(
7676
*/
7777
internal fun resetToInitialPool(emitUpdateEvents: Boolean) {
7878
pool.entries.removeIf { (key, _) -> key != ROOT_OBJECT_ID } // only keep the root object
79-
clearObjectsData(emitUpdateEvents) // clear the root object and emit update events
79+
clearObjectsData(emitUpdateEvents) // RTO4b2a - clear the root object and emit update events
8080
}
8181

8282

0 commit comments

Comments
 (0)