Skip to content

Commit

Permalink
fix: resolve ktor3 api breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Nov 3, 2024
1 parent 55c24c9 commit a0b2d0c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import io.ktor.server.websocket.WebSockets
import io.ktor.server.websocket.pingPeriod
import io.ktor.server.websocket.timeout
import io.ktor.websocket.WebSocketDeflateExtension
import java.time.Duration
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds

public fun Application.main() {
install(Compression) {
Expand All @@ -36,8 +37,8 @@ public fun Application.main() {
}

install(WebSockets) {
pingPeriod = Duration.ofSeconds(15)
timeout = Duration.ofSeconds(5)
pingPeriod = 15.seconds
timeout = 5.seconds

extensions { install(WebSocketDeflateExtension) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package net.kyori.adventure.webui.jvm.minimessage

import io.ktor.http.HttpStatusCode
import io.ktor.server.application.Application
import io.ktor.server.application.call
import io.ktor.server.http.content.defaultResource
import io.ktor.server.http.content.resource
import io.ktor.server.http.content.resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import io.ktor.network.sockets.openWriteChannel
import io.ktor.server.application.Application
import io.ktor.utils.io.ByteReadChannel
import io.ktor.utils.io.ByteWriteChannel
import io.ktor.utils.io.close
import io.ktor.utils.io.readByte
import io.ktor.utils.io.readFully
import io.ktor.utils.io.readShort
import io.ktor.utils.io.writeByte
import io.ktor.utils.io.writeFully
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -97,7 +99,7 @@ public class ServerStatusPreviewManager(
}
}

sendChannel.close()
sendChannel.flushAndClose()
} catch (e: Exception) {
logger.error("An unknown error occurred whilst responding to a ping from ${socket.remoteAddress}", e)
}
Expand Down Expand Up @@ -157,11 +159,11 @@ public class ServerStatusPreviewManager(
var value = int
while (true) {
if ((value and 0x7F.inv()) == 0) {
writeByte(value)
writeByte(value.toByte())
return
}

writeByte((value and 0x7F) or 0x80)
writeByte(((value and 0x7F) or 0x80).toByte())

value = value ushr 7
}
Expand Down

0 comments on commit a0b2d0c

Please sign in to comment.