Skip to content

Commit

Permalink
Upgrade Ktor
Browse files Browse the repository at this point in the history
  • Loading branch information
kotcrab committed Jun 16, 2024
1 parent 32e46ef commit 0431210
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,8 +50,8 @@ class PpssppWsClient(
}

private val client = HttpClient(CIO) {
install(JsonFeature) {
serializer = GsonSerializer()
install(ContentNegotiation) {
gson()
}
install(WebSockets)
}
Expand Down Expand Up @@ -96,7 +96,7 @@ class PpssppWsClient(

private suspend fun getPpssppInstances(): List<PpssppInstance> {
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]
Expand Down Expand Up @@ -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))
}
}

Expand Down

0 comments on commit 0431210

Please sign in to comment.