From f9893e2a17e357cc45003fb05c73a205d92dbdd4 Mon Sep 17 00:00:00 2001 From: Arindy Date: Mon, 10 Feb 2025 21:30:11 +0100 Subject: [PATCH] overwrites dice-overlay sse, so that only the last instance rolls the dice --- src/main/kotlin/de/arindy/dicetower/DiceResource.kt | 6 ++---- src/main/resources/templates/pub/index.html | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/de/arindy/dicetower/DiceResource.kt b/src/main/kotlin/de/arindy/dicetower/DiceResource.kt index f0b2dea..b13bbb8 100644 --- a/src/main/kotlin/de/arindy/dicetower/DiceResource.kt +++ b/src/main/kotlin/de/arindy/dicetower/DiceResource.kt @@ -63,9 +63,7 @@ final class DiceResource(@Context val sse: Sse) { @Path("/stream") @Produces(MediaType.SERVER_SENT_EVENTS) fun stream(@PathParam("id") id: String, @Context sseEventSink: SseEventSink) { - if (!sseBroadcasters.containsKey(id)) { - sseBroadcasters[id] = sse.newBroadcaster() - } + sseBroadcasters[id] = sse.newBroadcaster() sseBroadcasters[id]?.register(sseEventSink) } @@ -90,6 +88,6 @@ final class DiceResource(@Context val sse: Sse) { } @RegisterForReflection - data class Result(val name: String, val user: String, val themeColor: String) {} + data class Result(val name: String, val user: String, val themeColor: String) } diff --git a/src/main/resources/templates/pub/index.html b/src/main/resources/templates/pub/index.html index b269b95..4ff7bd0 100644 --- a/src/main/resources/templates/pub/index.html +++ b/src/main/resources/templates/pub/index.html @@ -292,7 +292,7 @@
-

Only open Overlay once, unless you want multiple results

+

Only the last loaded instance of that overlay rolls the dice!

Query Params you can Change: