diff --git a/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/DataBrokerTransporter.kt b/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/DataBrokerTransporter.kt index c06c43d6..ecea7043 100644 --- a/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/DataBrokerTransporter.kt +++ b/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/DataBrokerTransporter.kt @@ -153,7 +153,7 @@ internal class DataBrokerTransporter( val entry = entryUpdate.entry subscription.listeners.forEach { observer -> - observer.onPropertyChanged(vssPath, field, entry) + observer.onPropertyChanged(entry.path, field, entry) } } diff --git a/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/DataBrokerSubscriber.kt b/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/DataBrokerSubscriber.kt index a53b159f..f2e26c08 100644 --- a/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/DataBrokerSubscriber.kt +++ b/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/DataBrokerSubscriber.kt @@ -25,11 +25,11 @@ import org.eclipse.kuksa.DataBrokerTransporter import org.eclipse.kuksa.PropertyListener import org.eclipse.kuksa.VssSpecificationListener import org.eclipse.kuksa.extension.TAG -import org.eclipse.kuksa.extension.createProperties import org.eclipse.kuksa.proto.v1.Types import org.eclipse.kuksa.proto.v1.Types.Field import org.eclipse.kuksa.vsscore.model.VssProperty import org.eclipse.kuksa.vsscore.model.VssSpecification +import org.eclipse.kuksa.vsscore.model.vssProperties /** * Creates [Subscription]s to the DataBroker to get notified about changes on the underlying vssPaths and fields. @@ -91,13 +91,13 @@ internal class DataBrokerSubscriber(private val dataBrokerTransporter: DataBroke field: Field = Field.FIELD_VALUE, listener: VssSpecificationListener, ) { - val leafProperties = specification.createProperties(field) - val vssPaths = leafProperties.map { it.vssPath } + val vssPath = specification.vssPath - val specificationPropertyListener = SpecificationPropertyListener(specification, vssPaths, listener) - vssPaths.forEach { vssPath -> - subscribe(vssPath, field, specificationPropertyListener) - } + val leafProperties = specification.vssProperties + val childPropertiesPaths = leafProperties.map { it.vssPath } + + val specificationPropertyListener = SpecificationPropertyListener(specification, childPropertiesPaths, listener) + subscribe(vssPath, field, specificationPropertyListener) } /** @@ -111,13 +111,13 @@ internal class DataBrokerSubscriber(private val dataBrokerTransporter: DataBroke field: Field = Field.FIELD_VALUE, listener: VssSpecificationListener, ) { - val leafProperties = specification.createProperties(field) - val vssPaths = leafProperties.map { it.vssPath } + val vssPath = specification.vssPath - val specificationPropertyListener = SpecificationPropertyListener(specification, vssPaths, listener) - vssPaths.forEach { vssPath -> - unsubscribe(vssPath, field, specificationPropertyListener) - } + val leafProperties = specification.vssProperties + val childPropertiesPaths = leafProperties.map { it.vssPath } + + val specificationPropertyListener = SpecificationPropertyListener(specification, childPropertiesPaths, listener) + unsubscribe(vssPath, field, specificationPropertyListener) } private companion object { diff --git a/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/SpecificationPropertyListener.kt b/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/SpecificationPropertyListener.kt index 4de50f5d..7c95ec67 100644 --- a/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/SpecificationPropertyListener.kt +++ b/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/SpecificationPropertyListener.kt @@ -35,7 +35,6 @@ internal class SpecificationPropertyListener( vssPaths: Collection, private val listener: VssSpecificationListener, ) : PropertyListener { - // TODO: Remove as soon as the server supports subscribing to vssPaths which are not VssProperties // Reduces the load on the observer for big VssSpecifications. We wait for the initial update // of all VssProperties before notifying the observer about the first batch private val initialSubscriptionUpdates = vssPaths.associateWith { false }.toMutableMap() diff --git a/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/Subscription.kt b/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/Subscription.kt index 56419740..4d4cd6e9 100644 --- a/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/Subscription.kt +++ b/kuksa-sdk/src/main/kotlin/org/eclipse/kuksa/subscription/Subscription.kt @@ -50,7 +50,7 @@ internal class Subscription( for (entryUpdate in lastSubscribeResponse.updatesList) { val entry = entryUpdate.entry - observer.onPropertyChanged(vssPath, field, entry) + observer.onPropertyChanged(entry.path, field, entry) } } },