Add action to the character sheet detail panel.

This commit is contained in:
Thomas Andres Gomez 2025-02-27 15:36:07 +01:00
parent b6d02c21be
commit 1fe75062b7
14 changed files with 469 additions and 56 deletions

View file

@ -17,6 +17,7 @@ dependencies {
implementation(projects.shared)
implementation(libs.logback)
implementation(libs.koin.ktor)
implementation(libs.kotlinx.serialization.json)
implementation(libs.ktor.server.core)
implementation(libs.ktor.server.netty)
implementation(libs.ktor.server.websockets)

View file

@ -4,7 +4,7 @@ import com.pixelized.shared.lwa.protocol.websocket.Message
import io.ktor.websocket.Frame
import io.ktor.websocket.readText
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.encodeToJsonElement
fun Json.decodeFromFrame(frame: Frame.Text): Message {
val json = frame.readText()
@ -12,6 +12,6 @@ fun Json.decodeFromFrame(frame: Frame.Text): Message {
}
fun Json.encodeToFrame(message: Message): Frame {
val json = encodeToJsonElement(message)
return Frame.Text(text = json.toString())
val json = encodeToString(message)
return Frame.Text(text = json)
}

View file

@ -81,7 +81,8 @@ class LocalServer {
val job = launch {
// send local message to the clients
engine.webSocket.collect { message ->
send(json.encodeToFrame(message))
val frame = json.encodeToFrame(message)
send(frame)
}
}
runCatching {