diff --git a/build.gradle b/build.gradle index b10b74b..43127ed 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ if (ghidraInstallDir) { buildscript { ext.kotlinVersion = '1.9.24' ext.kotlinCoroutinesVersion = '1.6.3-native-mt' - ext.ktorVersion = '1.6.8' + ext.ktorVersion = '2.3.11' ext.testGsonVersion = '2.9.0' ext.testLog4j2Version = '2.23.1' repositories { @@ -60,10 +60,11 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinCoroutinesVersion" implementation "io.ktor:ktor-client-core:$ktorVersion" implementation "io.ktor:ktor-client-cio:$ktorVersion" - implementation("io.ktor:ktor-client-gson:$ktorVersion") { + implementation "io.ktor:ktor-client-websockets:$ktorVersion" + implementation "io.ktor:ktor-client-content-negotiation:$ktorVersion" + implementation("io.ktor:ktor-serialization-gson:$ktorVersion") { exclude group: 'com.google.code.gson', module: 'gson' // already provided by Ghidra } - implementation "io.ktor:ktor-client-websockets:$ktorVersion" testImplementation "com.google.code.gson:gson:$testGsonVersion" testImplementation "org.apache.logging.log4j:log4j-api:$testLog4j2Version" testImplementation "org.apache.logging.log4j:log4j-core:$testLog4j2Version" diff --git a/src/main/kotlin/allegrex/agent/ppsspp/client/websocket/PpssppWsClient.kt b/src/main/kotlin/allegrex/agent/ppsspp/client/websocket/PpssppWsClient.kt index d490bf1..a7fe728 100644 --- a/src/main/kotlin/allegrex/agent/ppsspp/client/websocket/PpssppWsClient.kt +++ b/src/main/kotlin/allegrex/agent/ppsspp/client/websocket/PpssppWsClient.kt @@ -13,16 +13,16 @@ import allegrex.agent.ppsspp.client.model.request.PpssppGameStatusRequest import allegrex.agent.ppsspp.client.model.request.PpssppRequest import com.google.gson.Gson import io.ktor.client.HttpClient +import io.ktor.client.call.body import io.ktor.client.engine.cio.CIO -import io.ktor.client.features.json.GsonSerializer -import io.ktor.client.features.json.JsonFeature -import io.ktor.client.features.websocket.DefaultClientWebSocketSession -import io.ktor.client.features.websocket.WebSockets -import io.ktor.client.features.websocket.webSocketSession +import io.ktor.client.plugins.contentnegotiation.ContentNegotiation +import io.ktor.client.plugins.websocket.DefaultClientWebSocketSession +import io.ktor.client.plugins.websocket.WebSockets +import io.ktor.client.plugins.websocket.webSocketSession import io.ktor.client.request.get import io.ktor.http.HttpMethod -import io.ktor.http.cio.websocket.Frame -import io.ktor.http.cio.websocket.send +import io.ktor.serialization.gson.gson +import io.ktor.websocket.Frame import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi @@ -50,8 +50,8 @@ class PpssppWsClient( } private val client = HttpClient(CIO) { - install(JsonFeature) { - serializer = GsonSerializer() + install(ContentNegotiation) { + gson() } install(WebSockets) } @@ -96,7 +96,7 @@ class PpssppWsClient( private suspend fun getPpssppInstances(): List { return when { - connectionUrl.isNullOrBlank() -> client.get(REPORT_PPSSPP_URL) + connectionUrl.isNullOrBlank() -> client.get(REPORT_PPSSPP_URL).body() else -> { val parts = connectionUrl.split(":", limit = 2) val ip = parts[0] @@ -128,7 +128,7 @@ class PpssppWsClient( for (message in outgoingChannel) { val request = gson.toJson(message) logger.debug(">>> WS ${request.take(MAX_WS_LOG_LENGTH)}") - session.send(request) + session.send(Frame.Text(request)) } }