Skip to content

MukjepScarlet/Rcon-Kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published

Languages