Replace even id counter with uuid
This commit is contained in:
parent
f0acbbb8cc
commit
32c29240d2
@ -27,6 +27,9 @@ import kotlinx.coroutines.flow.*
|
|||||||
import kotlinx.html.*
|
import kotlinx.html.*
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
|
import ru.mipt.npm.ktor.sse.SseEvent
|
||||||
|
import ru.mipt.npm.ktor.sse.writeSseFlow
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
public typealias GenericMagixMessage = MagixMessage<JsonElement>
|
public typealias GenericMagixMessage = MagixMessage<JsonElement>
|
||||||
|
|
||||||
@ -130,10 +133,10 @@ public fun Application.magixModule(magixFlow: MutableSharedFlow<GenericMagixMess
|
|||||||
//SSE server. Filter from query
|
//SSE server. Filter from query
|
||||||
get("sse") {
|
get("sse") {
|
||||||
val filter = call.buildFilter()
|
val filter = call.buildFilter()
|
||||||
var idCounter = 0
|
|
||||||
val sseFlow = magixFlow.filter(filter).map {
|
val sseFlow = magixFlow.filter(filter).map {
|
||||||
val data = magixJson.encodeToString(genericMessageSerializer, it)
|
val data = magixJson.encodeToString(genericMessageSerializer, it)
|
||||||
SseEvent(data, id = idCounter++.toString())
|
val id = UUID.randomUUID()
|
||||||
|
SseEvent(data, id = id.toString(), event = "message")
|
||||||
}
|
}
|
||||||
call.respondSse(sseFlow)
|
call.respondSse(sseFlow)
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,13 @@ pluginManagement {
|
|||||||
rootProject.name = "dataforge-control"
|
rootProject.name = "dataforge-control"
|
||||||
|
|
||||||
include(
|
include(
|
||||||
// ":dataforge-device-core",
|
":dataforge-device-core",
|
||||||
// ":dataforge-device-tcp",
|
":dataforge-device-tcp",
|
||||||
// ":dataforge-device-serial",
|
":dataforge-device-serial",
|
||||||
// ":dataforge-device-server",
|
":dataforge-device-server",
|
||||||
// ":dataforge-magix-client",
|
":dataforge-magix-client",
|
||||||
// ":motors",
|
":motors",
|
||||||
// ":demo",
|
":demo",
|
||||||
":magix",
|
":magix",
|
||||||
":magix:magix-api",
|
":magix:magix-api",
|
||||||
":magix:magix-server",
|
":magix:magix-server",
|
||||||
|
Loading…
Reference in New Issue
Block a user