Message class hierarchy.

This commit is contained in:
Alexander Nozik 2020-12-15 14:01:03 +03:00
parent d68f5a9840
commit 93c82db08e
2 changed files with 13 additions and 2 deletions

View File

@ -75,6 +75,7 @@ public class DeviceController(
targetDevice = request.sourceDevice
)
}
is PropertySetMessage -> {
if (request.value == null) {
device.invalidateProperty(request.property)
@ -88,6 +89,7 @@ public class DeviceController(
targetDevice = request.sourceDevice
)
}
is ActionExecuteMessage -> {
ActionResultMessage(
action = request.action,
@ -96,6 +98,7 @@ public class DeviceController(
targetDevice = request.sourceDevice
)
}
is GetDescriptionMessage -> {
val descriptionMeta = Meta {
"properties" put {
@ -117,7 +120,14 @@ public class DeviceController(
)
}
is DescriptionMessage, is PropertyChangedMessage, is ActionResultMessage, is BinaryNotificationMessage, is DeviceErrorMessage, is EmptyDeviceMessage -> {
is DescriptionMessage,
is PropertyChangedMessage,
is ActionResultMessage,
is BinaryNotificationMessage,
is DeviceErrorMessage,
is EmptyDeviceMessage,
is DeviceLogMessage,
-> {
//Those messages are ignored
EmptyDeviceMessage(
sourceDevice = deviceTarget,

View File

@ -9,7 +9,7 @@ import kotlinx.serialization.json.decodeFromJsonElement
import kotlinx.serialization.json.encodeToJsonElement
@Serializable
public sealed class DeviceMessage{
public sealed class DeviceMessage {
public abstract val sourceDevice: String?
public abstract val targetDevice: String?
public abstract val comment: String?
@ -133,6 +133,7 @@ public data class EmptyDeviceMessage(
@SerialName("log")
public data class DeviceLogMessage(
val message: String,
val data: MetaItem<*>? = null,
override val sourceDevice: String? = null,
override val targetDevice: String? = null,
override val comment: String? = null,