create a FrameChannelConverter

This commit is contained in:
2025-03-11 19:05:03 +01:00
parent c84562afe6
commit 0fbea7903a
12 changed files with 136 additions and 130 deletions

View File

@@ -3,22 +3,11 @@ package eventDemo.app.command
import eventDemo.app.command.command.GameCommand
import eventDemo.libs.command.CommandStream
import eventDemo.libs.command.CommandStreamChannel
import eventDemo.libs.command.CommandStreamInMemory
import io.ktor.websocket.Frame
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.serialization.json.Json
/**
* A stream to publish and read the game command.
*/
class GameCommandStreamInMemory : CommandStreamInMemory<GameCommand>()
/**
* A stream to publish and read the game command.
*/
class GameCommandStream(
incoming: ReceiveChannel<Frame>,
) : CommandStream<GameCommand> by CommandStreamChannel(
incoming,
{ Json.decodeFromString(GameCommand.serializer(), it) },
)
incoming: ReceiveChannel<GameCommand>,
) : CommandStream<GameCommand> by CommandStreamChannel(incoming)