Skip to content

Commit 07cf37d

Browse files
committed
Merge branch 'dev' into prod
2 parents 428f07a + e8e4628 commit 07cf37d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

botfest/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencies {
4141
// Custom added dependencies (these are not part of the kordex template)
4242
implementation("io.ktor:ktor-serialization-gson:3.0.2")
4343
implementation("org.xerial:sqlite-jdbc:3.48.0.0")
44-
implementation("nl.theepicblock:java-sse-client:0.2.0")
44+
implementation("nl.theepicblock:java-sse-client:0.4.0")
4545
implementation(project(":common"))
4646
}
4747

botfest/src/main/kotlin/net/modfest/botfest/Platform.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import nl.theepicblock.sseclient.SseClient
3232
import nl.theepicblock.sseclient.SseEvent
3333
import java.net.URI
3434
import java.net.http.HttpRequest
35+
import kotlin.math.min
3536
import kotlin.time.Duration
3637

3738
val LOGGER = KotlinLogging.logger("Platform API")
@@ -294,6 +295,7 @@ class PlatformBotFestAuthenticated(val client: HttpClient, val base_url: String)
294295
return object : SseClient() {
295296
init {
296297
this.retryDelayMillis = 5_000
298+
this.connect()
297299
}
298300

299301
override fun onEvent(e: SseEvent) {
@@ -328,11 +330,9 @@ class PlatformBotFestAuthenticated(val client: HttpClient, val base_url: String)
328330
java.time.Duration.ofMinutes(1)
329331
} else {
330332
// TODO need to expose the number of retries made in the SSE api
331-
java.time.Duration.ofMillis(when (1) {
332-
in 0..1 -> retryDelayMillis!!
333-
in 2..5 -> retryDelayMillis!! * retryDelayMillis!!
334-
else -> retryDelayMillis!! * 7
335-
})
333+
java.time.Duration.ofMillis(
334+
retryDelayMillis!! * min(reconnectionInfo.numberOfRetries(), 7)
335+
)
336336
}
337337
LOGGER.debug { "Attempting to reconnect to platform SSE in $reconnTime. " +
338338
"(did connect = ${!reconnectionInfo.connectionFailed()}, " +

0 commit comments

Comments
 (0)