diff --git a/app/src/main/java/moe/rikaaa0928/uot/UogClient.kt b/app/src/main/java/moe/rikaaa0928/uot/UogClient.kt index b8864ff..bdf808e 100644 --- a/app/src/main/java/moe/rikaaa0928/uot/UogClient.kt +++ b/app/src/main/java/moe/rikaaa0928/uot/UogClient.kt @@ -42,15 +42,15 @@ class UogClient(val lPort: Int, val endpoint: String, val password: String) : Br return } stop.set(false) + val url = URL(endpoint) + val builder = AndroidChannelBuilder.forAddress(url.host, url.port) + if (!url.protocol.equals("https")) { + builder.usePlaintext() + } GlobalScope.launch { while (!stop.get()) { try { val id = random.nextInt(1000); - val url = URL(endpoint) - val builder = AndroidChannelBuilder.forAddress(url.host, url.port) - if (!url.protocol.equals("https")) { - builder.usePlaintext() - } val channel = builder.build() val service = UdpServiceGrpcKt.UdpServiceCoroutineStub(channel) if (req != null) {