gpt4 book ai didi

Kotlin/Native 无法导入 io.ktor.network.selector.ActorSelectorManager

转载 作者:行者123 更新时间:2023-12-04 03:28:53 25 4
gpt4 key购买 nike

我想使用 KTOR 在 Kotlin/Native 中使用 TCP 套接字,我遵循了相应的 tutorial .但不知何故,我无法从 io.ktor.network.selector 导入 ActorSelectorManager 并获取 Unresolved reference: ActorSelectorManager

我的 build.gradle.kts 看起来像这样:

plugins {
kotlin("multiplatform") version "1.4.32"
kotlin("plugin.serialization") version "1.4.32"
}
repositories {
mavenCentral()
jcenter()
maven { url = uri("https://plugins.gradle.org/m2/") }
maven { url = uri("http://dl.bintray.com/kotlin/kotlin-dev") }
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
}

kotlin {
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val target = when {
hostOs == "Mac OS X" -> macosX64("SocketStuff")
hostOs == "Linux" -> linuxX64("SocketStuff")
isMingwX64 -> mingwX64("SocketStuff")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}

target.apply {
binaries {
executable {
entryPoint = "main"
}
}
}

sourceSets {
val Main by getting
val Test by getting
commonMain {
sourceSets["commonMain"].dependencies {
implementation("io.ktor:ktor-network:1.5.3")
}
}
}
}

有谁知道我是不是忘了添加依赖什么的?

最佳答案

在 JVM 上有 ActorSelectorManager,在本地目标上有 WorkerSelectorManager。您可以使用构造函数 SelectorManager() 来实例化适当的选择器管理器实例:

import io.ktor.network.selector.*

fun main() {
val manager = SelectorManager()
}

关于Kotlin/Native 无法导入 io.ktor.network.selector.ActorSelectorManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67218524/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com