Resolved #6445 - problems in hosting Unciv server

Solution from https://stackoverflow.com/questions/56533497/how-to-replace-blocking-code-for-reading-bytes-in-kotlin
This commit is contained in:
Yair Morgenstern 2022-04-17 13:26:04 +03:00
parent 6b99b11179
commit 8b5665a73f
2 changed files with 5 additions and 5 deletions

View File

@ -248,7 +248,7 @@ class Nation : RulesetObject() {
// This does not use the auto-linking FormattedLine(Unique) for two reasons:
// would look a little chaotic as unit uniques unlike most uniques are a HashSet and thus do not preserve order
// No .copy() factory on FormattedLine and no FormattedLine(Unique, all other val's) constructor either
if (unit.replacementTextForUniques.isNotEmpty()){
if (unit.replacementTextForUniques.isNotEmpty()) {
yield(FormattedLine(unit.replacementTextForUniques))
}
else for (unique in unit.uniqueObjects.filterNot { it.text in originalUnit.uniques || it.hasFlag(UniqueFlag.HiddenToUsers) }) {

View File

@ -48,10 +48,10 @@ private class UncivServerRunner : CliktCommand() {
put("/files/{fileName}") {
val fileName = call.parameters["fileName"] ?: throw Exception("No fileName!")
withContext(Dispatchers.IO) {
val recievedBytes =
call.request.receiveChannel().toInputStream().readAllBytes()
val textString = String(recievedBytes)
println("Recieved text: $textString")
val receivedBytes =
call.request.receiveChannel().toInputStream().readBytes()
val textString = String(receivedBytes)
println("Received text: $textString")
File(fileFolderName, fileName).writeText(textString)
}
}