Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 761 Bytes

README.md

File metadata and controls

28 lines (20 loc) · 761 Bytes

Rcon-Kotlin

Origin Repo

What's different, except language?

Change the class Rcon from a util-like class to a socket-like one, so you can:

  • Remove synchronized keywords
  • Use it like a Reader / Writer or something like that

You can call it in a coroutine scope like this:

withContext(Dispatchers.IO) {
    // calculate UPS for Factorio server
    val ups = Rcon("127.0.0.1", 24197, "my_pw").use {
        val prev = it.command("/sc rcon.print(game.tick)").toFloat()
        delay(60.seconds)
        val now = it.command("/sc rcon.print(game.tick)").toFloat()
        (now - prev) / 60F
    }
}

You can move these 3 files to any project you need, or as a dependency.

I hope you enjoy it.