rcon client supports

This commit is contained in:
2026-09-04 01:27:18 +08:00
parent 350b900aaa
commit 817ec27813
27 files changed
+412 -93

No files matched your search

@@ -8,12 +8,12 @@
package cn.rtast.mcping.bedrock
import cn.rtast.mcping.PingResponse
import cn.rtast.mcping.platform.PingContext
import cn.rtast.mcping.platform.MCPingContext
import cn.rtast.mcping.platform._UdpSocket
import cn.rtast.mcping.platform.wrap
import kotlin.time.Clock
internal fun pingBedrockServer(host: String, port: Int, context: PingContext): PingResponse {
internal fun pingBedrockServer(host: String, port: Int, context: MCPingContext): PingResponse {
val socket = _UdpSocket(host, port, context)
return try {
val sendTime = Clock.System.now().toEpochMilliseconds()
@@ -8,11 +8,11 @@
package cn.rtast.mcping.java
import cn.rtast.mcping.PingResponse
import cn.rtast.mcping.platform.PingContext
import cn.rtast.mcping.platform.MCPingContext
import cn.rtast.mcping.platform._Socket
import kotlin.time.Clock
internal fun pingJavaServer(host: String, port: Int, context: PingContext): PingResponse {
internal fun pingJavaServer(host: String, port: Int, context: MCPingContext): PingResponse {
val socket = _Socket(host, port, context)
val receiveChannel = socket.openReadChannel()
val sendChannel = socket.openWriteChannel()
@@ -11,7 +11,7 @@ package cn.rtast.mcping
import cn.rtast.mcping.bedrock.pingBedrockServer
import cn.rtast.mcping.java.pingJavaServer
import cn.rtast.mcping.platform.PingContext
import cn.rtast.mcping.platform.MCPingContext
import kotlin.jvm.JvmName
import kotlin.jvm.JvmOverloads
@@ -20,7 +20,7 @@ public fun mcping(
host: String,
port: Int,
type: ServerType = ServerType.Java,
context: PingContext = PingContext(),
context: MCPingContext = MCPingContext(),
): PingResponse = when (type) {
ServerType.Java -> pingJavaServer(host, port, context)
ServerType.Bedrock -> pingBedrockServer(host, port, context)
@@ -9,7 +9,7 @@ package test
import cn.rtast.mcping.ServerType
import cn.rtast.mcping.mcping
import cn.rtast.mcping.platform.PingContext
import cn.rtast.mcping.platform.MCPingContext
import io.ktor.network.selector.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
@@ -22,7 +22,7 @@ class TestMingwPing {
fun `test ping java on mingw with selectorManager`() = runTest {
val sm = SelectorManager(Dispatchers.IO)
val response =
mcping(host = "org.mc-complex.com", port = 25565, type = ServerType.Java, context = PingContext(sm))
mcping(host = "org.mc-complex.com", port = 25565, type = ServerType.Java, context = MCPingContext(sm))
println(response)
}
@@ -30,7 +30,7 @@ class TestMingwPing {
fun `test ping bedrock on mingw with selectorManager`() = runTest {
val sm = SelectorManager(Dispatchers.IO)
val response =
mcping(host = "play.wildnetwork.net", port = 19132, type = ServerType.Bedrock, context = PingContext(sm))
mcping(host = "play.wildnetwork.net", port = 19132, type = ServerType.Bedrock, context = MCPingContext(sm))
println(response)
println(response.toBedrockResponse())
}