mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-02 20:35:43 +00:00
complete native integration
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor
|
||||
|
||||
import dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor
|
||||
|
||||
actual typealias KtorRequestsExecutor = MultipleClientKtorRequestsExecutor
|
||||
actual typealias KtorRequestsExecutor = DefaultKtorRequestsExecutor
|
||||
|
||||
@@ -5,20 +5,10 @@ import io.ktor.client.engine.winhttp.*
|
||||
|
||||
/**
|
||||
* This function is used in default constructor of [MultipleClientKtorRequestsExecutor] and on all non-native
|
||||
* platforms should return [client]
|
||||
* platforms and MingwX64 should return [client]
|
||||
*
|
||||
* On LinuxX64 it will create copy with Curl engine or throw an exception if engine is different with Curl
|
||||
* On MingwX64 it will create copy with WinHttp engine or throw an exception if engine is different with WinHttp
|
||||
*
|
||||
* @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 or non WinHttp-based [HttpClient]
|
||||
* on MingwX64
|
||||
* @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64
|
||||
*/
|
||||
internal actual inline fun platformClientCopy(client: HttpClient): HttpClient = (client.engineConfig as? WinHttpClientEngineConfig) ?.let { engineConfig ->
|
||||
lateinit var config: HttpClientConfig<out WinHttpClientEngineConfig>
|
||||
client.config {
|
||||
config = this as HttpClientConfig<out WinHttpClientEngineConfig>
|
||||
}.close()
|
||||
HttpClient(WinHttp) {
|
||||
this.plusAssign(config)
|
||||
}
|
||||
} ?: throw IllegalArgumentException("On LinuxX64 TelegramBotAPI currently support only Curl Ktor HttpClient engine")
|
||||
internal actual inline fun platformClientCopy(client: HttpClient): HttpClient = client.config { }
|
||||
|
||||
Reference in New Issue
Block a user