An RCON client library for Java and Kotlin (JVM/Android).
Depends on: kotlin-stdlib
rcon4j-core
: Based on Java Socket API.rcon4j-kotlin
: Based on ktor-network (CIO) library and Kotlin coroutines.
- Include the JitPack repository to your project, example (
build.gradle.kts
):repositories { mavenCentral() maven("https://jitpack.io") }
- Import the library with a proper version:
dependencies { implementation("com.github.MukjepScarlet.rcon4j:rcon4j-core:$version") implementation("com.github.MukjepScarlet.rcon4j:rcon4j-kotlin:$version") }
Default Charset: StandardCharsets.UTF_8
Default request ID: Random.nextInt(1, Int.MAX_VALUE)
(Kotlin thread-safe Random)
// Packet
class RconPacket(int id, int type, byte[] payload) { /*...*/ }
class RconClient implements AutoCloseable {
public RconClient(
String host,
int port,
String password,
Charset charset, // default
int requestId // default
) throws IOException, AuthenticationException { /*...*/ }
@NotNull
public String command(@NotNull String payload) throws IOException { /*...*/ }
}
suspend fun ARconClient(
host: String,
port: Int,
password: String,
charset: Charset, // default
requestId: Int, // default
socketBuilder: SocketBuilder,
): ARconClient { /*...*/ }
suspend fun ARconClient.command(payload: String): String { /*...*/ }