File tree Expand file tree Collapse file tree 6 files changed +18
-6
lines changed
server/src/main/kotlin/application
shared/src/commonMain/kotlin/network Expand file tree Collapse file tree 6 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 11import io.ktor.client.engine.js.*
2+ import korlibs.io.async.launchUnscopedAndWait
3+ import korlibs.io.file.std.resourcesVfs
4+ import korlibs.io.lang.readProperties
25import network.ClientEngineFactory
36import network.URLProvider
47import org.koin.core.context.startKoin
58import org.koin.dsl.bind
69import org.koin.dsl.module
710import org.koin.mp.KoinPlatform
11+ import util.launchNow
12+ import kotlin.coroutines.CoroutineContext
813
914suspend 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 {
Original file line number Diff line number Diff line change @@ -5,13 +5,17 @@ import org.koin.core.context.startKoin
55import org.koin.dsl.bind
66import org.koin.dsl.module
77import org.koin.mp.KoinPlatform
8+ import java.io.File
9+ import java.util.Properties
810
911suspend 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 {
Original file line number Diff line number Diff line change @@ -2,4 +2,3 @@ org.gradle.jvmargs=-Xmx4g
22kotlin.mpp.stability.nowarn =true
33# org.gradle.unsafe.configuration-cache=true
44kotlin.mpp.androidSourceSetLayoutVersion1.nowarn =true
5- version =test
Original file line number Diff line number Diff 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)
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ lateinit var sessionId: String
1717private fun generateUsername () = UUID .generateUUID().toString().substring(0 , 4 )
1818
1919suspend 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 }
You can’t perform that action at this time.
0 commit comments