From 8eff7c7b9378795dea88b52bad77bd71661f3895 Mon Sep 17 00:00:00 2001 From: Nek-12 Date: Wed, 6 Mar 2024 15:19:32 +0300 Subject: [PATCH] fixes to event serialization for debuger --- .../respawn/flowmvi/debugger/model/ClientEvent.kt | 12 ++++++++++++ .../respawn/flowmvi/debugger/server/DebugServer.kt | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/debugger/debugger-common/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/model/ClientEvent.kt b/debugger/debugger-common/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/model/ClientEvent.kt index 006338c3..0e6fca28 100644 --- a/debugger/debugger-common/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/model/ClientEvent.kt +++ b/debugger/debugger-common/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/model/ClientEvent.kt @@ -4,6 +4,7 @@ package pro.respawn.flowmvi.debugger.model import com.benasher44.uuid.Uuid +import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers import pro.respawn.flowmvi.api.MVIAction @@ -13,30 +14,36 @@ import pro.respawn.flowmvi.debugger.name import pro.respawn.flowmvi.debugger.serializers.UUIDSerializer @Serializable +@SerialName("client") public sealed interface ClientEvent : MVIIntent { @Serializable + @SerialName("connected") public data class StoreConnected( val name: String, val id: Uuid, ) : ClientEvent @Serializable + @SerialName("disconnected") public data class StoreDisconnected( val id: Uuid, ) : ClientEvent @Serializable + @SerialName("started") public data class StoreStarted( val name: String, ) : ClientEvent @Serializable + @SerialName("stopped") public data class StoreStopped( val name: String, ) : ClientEvent @Serializable + @SerialName("intent") public data class StoreIntent( val name: String, val data: String, @@ -46,6 +53,7 @@ public sealed interface ClientEvent : MVIIntent { } @Serializable + @SerialName("action") public data class StoreAction( val name: String, val data: String, @@ -55,6 +63,7 @@ public sealed interface ClientEvent : MVIIntent { } @Serializable + @SerialName("state_change") public data class StoreStateChanged( val from: StoreState, val to: StoreState, @@ -64,16 +73,19 @@ public sealed interface ClientEvent : MVIIntent { } @Serializable + @SerialName("unsubscribed") public data class StoreUnsubscribed( val newSubscriptionCount: Int, ) : ClientEvent @Serializable + @SerialName("subscribed") public data class StoreSubscribed( val newSubscriptionCount: Int, ) : ClientEvent @Serializable + @SerialName("exception") public data class StoreException( val name: String, val message: String?, diff --git a/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/DebugServer.kt b/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/DebugServer.kt index 28ecadb8..1514d152 100644 --- a/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/DebugServer.kt +++ b/debugger/server/src/commonMain/kotlin/pro/respawn/flowmvi/debugger/server/DebugServer.kt @@ -18,6 +18,7 @@ import kotlinx.coroutines.supervisorScope import pro.respawn.flowmvi.api.Container import pro.respawn.flowmvi.debugger.model.ClientEvent import pro.respawn.flowmvi.debugger.model.ClientEvent.StoreDisconnected +import pro.respawn.flowmvi.debugger.model.ServerEvent import pro.respawn.flowmvi.debugger.server.ServerAction.SendClientEvent import pro.respawn.flowmvi.debugger.server.ServerIntent.EventReceived import pro.respawn.flowmvi.debugger.server.ServerIntent.ServerStarted @@ -49,7 +50,7 @@ internal object DebugServer : Container actions .filterIsInstance() .filter { it.client == storeId } - .collect { sendSerialized(it.event) } + .collect { sendSerialized(it.event) } } launch { while (true) {