From b787fabb1ccb6c2862b31e26c8e98829304a4d2c Mon Sep 17 00:00:00 2001 From: Sudo Dios Date: Wed, 15 May 2024 14:16:48 +0330 Subject: [PATCH] Handle failed connection --- src/main/kotlin/core/Service.kt | 2 ++ src/main/kotlin/routes/sections/home/TestStage.kt | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/main/kotlin/core/Service.kt b/src/main/kotlin/core/Service.kt index ce8bd99..bbbbb0b 100644 --- a/src/main/kotlin/core/Service.kt +++ b/src/main/kotlin/core/Service.kt @@ -46,6 +46,7 @@ object Service { var running = MutableLiveData(false) var goToResult : () -> Unit = {} + var onError : (String?) -> Unit = {} fun init () { speedTestHandler = SpeedTestHandler() @@ -151,6 +152,7 @@ object Service { running.value = false } override fun onCriticalFailure(err: String?) { + onError.invoke(err) currentStep.value = "FAILED" running.value = false } diff --git a/src/main/kotlin/routes/sections/home/TestStage.kt b/src/main/kotlin/routes/sections/home/TestStage.kt index e3df02c..ca5a3ab 100644 --- a/src/main/kotlin/routes/sections/home/TestStage.kt +++ b/src/main/kotlin/routes/sections/home/TestStage.kt @@ -45,6 +45,9 @@ fun TestStage(onCancel : () -> Unit,goToResult : () -> Unit) { Service.goToResult = { goToResult.invoke() } + Service.onError = { + onCancel.invoke() + } delay(3000) enablecancelation = true }