@@ -3,6 +3,7 @@ package io.ably.lib.objects
33import io.ably.lib.types.Callback
44import io.ably.lib.types.ProtocolMessage
55import io.ably.lib.util.Log
6+ import java.util.*
67
78internal class DefaultLiveObjects (private val channelName : String , private val adapter : LiveObjectsAdapter ): LiveObjects {
89 private val tag = DefaultLiveObjects ::class .simpleName
@@ -47,14 +48,22 @@ internal class DefaultLiveObjects(private val channelName: String, private val a
4748 TODO (" Not yet implemented" )
4849 }
4950
50- fun handle (msg : ProtocolMessage ) {
51+ fun handle (protocolMessage : ProtocolMessage ) {
5152 // RTL15b
52- msg .channelSerial?.let {
53- if (msg .action == = ProtocolMessage .Action .`object `) {
54- Log .v(tag, " Setting channel serial for channelName: $channelName , value: ${msg .channelSerial} " )
55- adapter.setChannelSerial(channelName, msg .channelSerial)
53+ protocolMessage .channelSerial?.let {
54+ if (protocolMessage .action == = ProtocolMessage .Action .`object `) {
55+ Log .v(tag, " Setting channel serial for channelName: $channelName , value: ${protocolMessage .channelSerial} " )
56+ adapter.setChannelSerial(channelName, protocolMessage .channelSerial)
5657 }
5758 }
59+ // Populate missing fields from parent
60+ val objects = protocolMessage.state.filterIsInstance<ObjectMessage >().mapIndexed { index, stateItem ->
61+ stateItem.copy(
62+ connectionId = stateItem.connectionId ? : protocolMessage.connectionId,
63+ timestamp = stateItem.timestamp ? : protocolMessage.timestamp,
64+ id = stateItem.id ? : (protocolMessage.id + ' :' + index)
65+ )
66+ }
5867 }
5968
6069 fun dispose () {
0 commit comments