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.serialization.KSerializer
|
||||
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>
|
||||
|
||||
@ -130,10 +133,10 @@ public fun Application.magixModule(magixFlow: MutableSharedFlow<GenericMagixMess
|
||||
//SSE server. Filter from query
|
||||
get("sse") {
|
||||
val filter = call.buildFilter()
|
||||
var idCounter = 0
|
||||
val sseFlow = magixFlow.filter(filter).map {
|
||||
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)
|
||||
}
|
||||
|
@ -27,13 +27,13 @@ pluginManagement {
|
||||
rootProject.name = "dataforge-control"
|
||||
|
||||
include(
|
||||
// ":dataforge-device-core",
|
||||
// ":dataforge-device-tcp",
|
||||
// ":dataforge-device-serial",
|
||||
// ":dataforge-device-server",
|
||||
// ":dataforge-magix-client",
|
||||
// ":motors",
|
||||
// ":demo",
|
||||
":dataforge-device-core",
|
||||
":dataforge-device-tcp",
|
||||
":dataforge-device-serial",
|
||||
":dataforge-device-server",
|
||||
":dataforge-magix-client",
|
||||
":motors",
|
||||
":demo",
|
||||
":magix",
|
||||
":magix:magix-api",
|
||||
":magix:magix-server",
|
||||
|
Loading…
Reference in New Issue
Block a user