Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.ably.lib.objects
import io.ably.lib.types.Callback
import io.ably.lib.types.ProtocolMessage
import io.ably.lib.util.Log
import java.util.*

internal class DefaultLiveObjects(private val channelName: String, private val adapter: LiveObjectsAdapter): LiveObjects {
private val tag = DefaultLiveObjects::class.simpleName
Expand Down Expand Up @@ -47,14 +48,22 @@ internal class DefaultLiveObjects(private val channelName: String, private val a
TODO("Not yet implemented")
}

fun handle(msg: ProtocolMessage) {
fun handle(protocolMessage: ProtocolMessage) {
// RTL15b
msg.channelSerial?.let {
if (msg.action === ProtocolMessage.Action.`object`) {
Log.v(tag, "Setting channel serial for channelName: $channelName, value: ${msg.channelSerial}")
adapter.setChannelSerial(channelName, msg.channelSerial)
protocolMessage.channelSerial?.let {
if (protocolMessage.action === ProtocolMessage.Action.`object`) {
Log.v(tag, "Setting channel serial for channelName: $channelName, value: ${protocolMessage.channelSerial}")
adapter.setChannelSerial(channelName, protocolMessage.channelSerial)
}
}
// Populate missing fields from parent
val objects = protocolMessage.state.filterIsInstance<ObjectMessage>().mapIndexed { index, stateItem ->
stateItem.copy(
connectionId = stateItem.connectionId ?: protocolMessage.connectionId,
timestamp = stateItem.timestamp ?: protocolMessage.timestamp,
id = stateItem.id ?: (protocolMessage.id + ':' + index)
)
}
}

fun dispose() {
Expand Down
Loading