From b89e7318b39fb020c200d5b6135c38329c04f0bd Mon Sep 17 00:00:00 2001 From: rikaaa0928 Date: Mon, 14 Oct 2024 14:05:07 +0800 Subject: [PATCH] move builder out --- app/src/main/java/moe/rikaaa0928/uot/UogClient.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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) {