Commit 8d820af6 authored by Lisa (AI Assistant)'s avatar Lisa (AI Assistant)

Fix: Use 5s Handler delay

parent 702616dd
...@@ -143,12 +143,10 @@ class NodeService : Service() { ...@@ -143,12 +143,10 @@ class NodeService : Service() {
val fullUrl = if (protocol == "WSS") "wss://$ip:$port" else "ws://$ip:$port" val fullUrl = if (protocol == "WSS") "wss://$ip:$port" else "ws://$ip:$port"
// Delay startup briefly to let startForeground settle // Use Handler to delay startup - this runs on main thread after onStartCommand returns
// Use coroutine delay to avoid Handler issues android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
scope.launch { scope.launch { startNode(fullUrl, token, nodeId) }
delay(3000) // Wait 3 seconds before starting }, 5000) // 5 second delay to let startForeground fully settle
startNode(fullUrl, token, nodeId)
}
} }
"STOP" -> { "STOP" -> {
scope.launch { stopNode() } scope.launch { stopNode() }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment