Skip to content

Commit 74699b0

Browse files
committed
init
1 parent 9449a5b commit 74699b0

File tree

6 files changed

+18
-6
lines changed

6 files changed

+18
-6
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ jobs:
3030
path: './gradle.properties'
3131
property: |
3232
'version'
33+
'server'
3334
value: |
3435
'Build ${{github.run_number}}'
36+
'https://kotlingames.shop'
3537
3638
- run: git tag ${{github.run_number}}
3739

client/src/jsMain/kotlin/main.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
import io.ktor.client.engine.js.*
2+
import korlibs.io.async.launchUnscopedAndWait
3+
import korlibs.io.file.std.resourcesVfs
4+
import korlibs.io.lang.readProperties
25
import network.ClientEngineFactory
36
import network.URLProvider
47
import org.koin.core.context.startKoin
58
import org.koin.dsl.bind
69
import org.koin.dsl.module
710
import org.koin.mp.KoinPlatform
11+
import util.launchNow
12+
import kotlin.coroutines.CoroutineContext
813

914
suspend fun main() {
15+
val url = resourcesVfs["client.properties"].readProperties()
16+
.get("server")?: "http://localhost:8080"
1017
startKoin {}
1118
KoinPlatform.getKoin().loadModules(listOf(module {
1219
factory {
1320
object : URLProvider {
14-
override val url: String get() = "https://kotlingames.shop"
21+
override val url: String get() = url
1522
}
1623
} bind URLProvider::class
1724
factory {

client/src/jvmMain/kotlin/main.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ import org.koin.core.context.startKoin
55
import org.koin.dsl.bind
66
import org.koin.dsl.module
77
import org.koin.mp.KoinPlatform
8+
import java.io.File
9+
import java.util.Properties
810

911
suspend fun main() {
12+
val url = Properties().apply { load(File("client.properties").inputStream()) }
13+
.getOrDefault("server", "http://localhost:8080").toString()
1014
startKoin {}
1115
KoinPlatform.getKoin().loadModules(listOf(module {
1216
factory {
1317
object : URLProvider {
14-
override val url: String get() = "http://localhost:8080"
18+
override val url: String get() = url
1519
}
1620
} bind URLProvider::class
1721
factory {

gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ org.gradle.jvmargs=-Xmx4g
22
kotlin.mpp.stability.nowarn=true
33
#org.gradle.unsafe.configuration-cache=true
44
kotlin.mpp.androidSourceSetLayoutVersion1.nowarn=true
5-
version=test

server/src/main/kotlin/application/authentication.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ fun Application.configureAuthentication() {
3333
}
3434
}
3535
routing {
36-
get("login") {
36+
post("login") login@{
3737
val loginRequest = call.receive<LoginRequest>()
3838
val sessionPlayer = try {
3939
newPlayer(loginRequest.username)
4040
} catch (e: Throwable) {
4141
e.printStackTrace()
4242
call.respond(HttpStatusCode.NotAcceptable)
43-
return@get
43+
return@login
4444
}
4545
val uuid = newSession(sessionPlayer).id.value
4646
call.respond(uuid)

shared/src/commonMain/kotlin/network/Login.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ lateinit var sessionId: String
1717
private fun generateUsername() = UUID.generateUUID().toString().substring(0, 4)
1818

1919
suspend fun login() {
20-
val response = client.get("$currentUrl/login") {
20+
val response = client.post("$currentUrl/login") {
2121
contentType(ContentType.Application.Json)
2222
setBody(LoginRequest(username))
2323
}

0 commit comments

Comments
 (0)