1
0
2025-04-21 17:44:40 +03:00

41 lines
814 B
Kotlin

/*
* Created by sweetbread
* Copyright (c) 2025. All rights reserved.
*/
package ru.risdeveau.geotracker
import io.ktor.client.*
import io.ktor.client.engine.okhttp.OkHttp
import io.ktor.client.plugins.logging.*
import io.ktor.client.request.get
import io.ktor.http.HttpStatusCode
val client = HttpClient(OkHttp) {
install(Logging) {
logger = Logger.ANDROID
level = LogLevel.ALL
}
}
data class GeoData(
val ln: Double,
val lt: Double,
val nick: String
)
/**
* Validate [baseurl] and check accessibility to a server
* @return true if baseurl is valid
*/
suspend fun health(baseurl: String): Boolean {
val r = client.get("$baseurl/health")
return r.status == HttpStatusCode.OK
}
/**
* Send data to a server
*/
fun sendGeo(baseurl: String, data: GeoData) {
}